CMS 3D CMS Logo

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

Public Member Functions

void beginRun (edm::Run const &iEvent, edm::EventSetup const &es) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 TICLCandidateProducer (const edm::ParameterSet &ps)
 
 ~TICLCandidateProducer () 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 &descriptions)
 

Private Member Functions

template<typename F >
void assignTimeToCandidates (std::vector< TICLCandidate > &resultCandidates, edm::Handle< std::vector< reco::Track >> track_h, MtdHostCollection::ConstView &inputTimingView, F func) const
 
void dumpCandidate (const TICLCandidate &) const
 

Private Attributes

edm::ESHandle< MagneticFieldbfield_
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordbfield_token_
 
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
 
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
 
const StringCutObjectSelector< reco::TrackcutTk_
 
const std::string detector_
 
std::vector< edm::EDGetTokenT< std::vector< std::vector< unsigned > > > > egamma_tracksterlinks_tokens_
 
std::vector< edm::EDGetTokenT< std::vector< Trackster > > > egamma_tracksters_tokens_
 
std::vector< edm::EDGetTokenT< std::vector< std::vector< unsigned > > > > general_tracksterlinks_tokens_
 
std::vector< edm::EDGetTokenT< std::vector< Trackster > > > general_tracksters_tokens_
 
std::unique_ptr< TICLInterpretationAlgoBase< reco::Track > > generalInterpretationAlgo_
 
const edm::ESGetToken< CaloGeometry, CaloGeometryRecordgeometry_token_
 
edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecordhdc_token_
 
const HGCalDDDConstantshgcons_
 
std::once_flag initializeGeometry_
 
edm::EDGetTokenT< MtdHostCollectioninputTimingToken_
 
const edm::EDGetTokenT< std::vector< reco::Muon > > muons_token_
 
std::vector< edm::EDGetTokenT< std::vector< float > > > original_masks_tokens_
 
edm::ESHandle< Propagatorpropagator_
 
const edm::ESGetToken< Propagator, TrackingComponentsRecordpropagator_token_
 
const std::string propName_
 
hgcal::RecHitTools rhtools_
 
const float timingQualityThreshold_
 
const float tkEnergyCut_ = 2.0f
 
edm::ESHandle< GlobalTrackingGeometrytrackingGeometry_
 
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecordtrackingGeometry_token_
 
const edm::EDGetTokenT< std::vector< reco::Track > > tracks_token_
 
const bool useMTDTiming_
 
const bool useTimingAverage_
 

Static Private Attributes

static constexpr float c_light_ = CLHEP::c_light * CLHEP::ns / CLHEP::cm
 
static constexpr float timeRes = 0.02f
 

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 58 of file TICLCandidateProducer.cc.

Constructor & Destructor Documentation

◆ TICLCandidateProducer()

TICLCandidateProducer::TICLCandidateProducer ( const edm::ParameterSet ps)
explicit

Definition at line 116 of file TICLCandidateProducer.cc.

References cms::cuda::assert(), detector_, egamma_tracksterlinks_tokens_, egamma_tracksters_tokens_, general_tracksterlinks_tokens_, general_tracksters_tokens_, generalInterpretationAlgo_, get, edm::ParameterSet::getParameter(), hdc_token_, inputTimingToken_, original_masks_tokens_, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, useMTDTiming_, and trackerHitRTTI::vector.

117  : clusters_token_(consumes<std::vector<reco::CaloCluster>>(ps.getParameter<edm::InputTag>("layer_clusters"))),
119  consumes<edm::ValueMap<std::pair<float, float>>>(ps.getParameter<edm::InputTag>("layer_clustersTime"))),
120  tracks_token_(consumes<std::vector<reco::Track>>(ps.getParameter<edm::InputTag>("tracks"))),
121  inputTimingToken_(consumes<MtdHostCollection>(ps.getParameter<edm::InputTag>("timingSoA"))),
122  muons_token_(consumes<std::vector<reco::Muon>>(ps.getParameter<edm::InputTag>("muons"))),
123  useMTDTiming_(ps.getParameter<bool>("useMTDTiming")),
124  useTimingAverage_(ps.getParameter<bool>("useTimingAverage")),
125  timingQualityThreshold_(ps.getParameter<double>("timingQualityThreshold")),
126  geometry_token_(esConsumes<CaloGeometry, CaloGeometryRecord, edm::Transition::BeginRun>()),
127  bfield_token_(esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>()),
128  detector_(ps.getParameter<std::string>("detector")),
129  propName_(ps.getParameter<std::string>("propagator")),
131  esConsumes<Propagator, TrackingComponentsRecord, edm::Transition::BeginRun>(edm::ESInputTag("", propName_))),
133  esConsumes<GlobalTrackingGeometry, GlobalTrackingGeometryRecord, edm::Transition::BeginRun>()),
134  cutTk_(ps.getParameter<std::string>("cutTk")) {
135  // These are the CLUE3DEM Tracksters put in the event by the TracksterLinksProducer with the superclustering algorithm
136  for (auto const &tag : ps.getParameter<std::vector<edm::InputTag>>("egamma_tracksters_collections")) {
137  egamma_tracksters_tokens_.emplace_back(consumes<std::vector<Trackster>>(tag));
138  }
139 
140  // These are the links put in the event by the TracksterLinksProducer with the superclustering algorithm
141  for (auto const &tag : ps.getParameter<std::vector<edm::InputTag>>("egamma_tracksterlinks_collections")) {
142  egamma_tracksterlinks_tokens_.emplace_back(consumes<std::vector<std::vector<unsigned int>>>(tag));
143  }
144 
145  //make sure that the number of tracksters collections and tracksterlinks collections is the same
147 
148  // Loop over the edm::VInputTag and append the token to general_tracksters_tokens_
149  // These, instead, are the tracksters already merged by the TrackstersLinksProducer
150  for (auto const &tag : ps.getParameter<std::vector<edm::InputTag>>("general_tracksters_collections")) {
151  general_tracksters_tokens_.emplace_back(consumes<std::vector<Trackster>>(tag));
152  }
153 
154  for (auto const &tag : ps.getParameter<std::vector<edm::InputTag>>("general_tracksterlinks_collections")) {
155  general_tracksterlinks_tokens_.emplace_back(consumes<std::vector<std::vector<unsigned int>>>(tag));
156  }
157 
158  //make sure that the number of tracksters collections and tracksterlinks collections is the same
160 
161  //Loop over the edm::VInputTag of masks and append the token to original_masks_tokens_
162  for (auto const &tag : ps.getParameter<std::vector<edm::InputTag>>("original_masks")) {
163  original_masks_tokens_.emplace_back(consumes<std::vector<float>>(tag));
164  }
165 
166  std::string detectorName_ = (detector_ == "HFNose") ? "HGCalHFNoseSensitive" : "HGCalEESensitive";
167  hdc_token_ =
168  esConsumes<HGCalDDDConstants, IdealGeometryRecord, edm::Transition::BeginRun>(edm::ESInputTag("", detectorName_));
169  if (useMTDTiming_) {
170  inputTimingToken_ = consumes<MtdHostCollection>(ps.getParameter<edm::InputTag>("timingSoA"));
171  }
172 
173  produces<std::vector<TICLCandidate>>();
174 
175  // New trackster collection after linking
176  produces<std::vector<Trackster>>();
177 
178  auto interpretationPSet = ps.getParameter<edm::ParameterSet>("interpretationDescPSet");
179  auto algoType = interpretationPSet.getParameter<std::string>("type");
181  TICLGeneralInterpretationPluginFactory::get()->create(algoType, interpretationPSet, consumesCollector());
182 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const StringCutObjectSelector< reco::Track > cutTk_
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bfield_token_
assert(be >=bs)
const edm::EDGetTokenT< std::vector< reco::Track > > tracks_token_
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagator_token_
edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > hdc_token_
std::vector< edm::EDGetTokenT< std::vector< Trackster > > > general_tracksters_tokens_
std::vector< edm::EDGetTokenT< std::vector< Trackster > > > egamma_tracksters_tokens_
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > trackingGeometry_token_
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
std::vector< edm::EDGetTokenT< std::vector< std::vector< unsigned > > > > general_tracksterlinks_tokens_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometry_token_
edm::EDGetTokenT< MtdHostCollection > inputTimingToken_
std::vector< edm::EDGetTokenT< std::vector< float > > > original_masks_tokens_
std::unique_ptr< TICLInterpretationAlgoBase< reco::Track > > generalInterpretationAlgo_
#define get
std::vector< edm::EDGetTokenT< std::vector< std::vector< unsigned > > > > egamma_tracksterlinks_tokens_
const edm::EDGetTokenT< std::vector< reco::Muon > > muons_token_

◆ ~TICLCandidateProducer()

TICLCandidateProducer::~TICLCandidateProducer ( )
inlineoverride

Definition at line 61 of file TICLCandidateProducer.cc.

61 {};

Member Function Documentation

◆ assignTimeToCandidates()

template<typename F >
void TICLCandidateProducer::assignTimeToCandidates ( std::vector< TICLCandidate > &  resultCandidates,
edm::Handle< std::vector< reco::Track >>  track_h,
MtdHostCollection::ConstView inputTimingView,
F  func 
) const
private

Definition at line 396 of file TICLCandidateProducer.cc.

References HLT_2024v13_cff::beta, c_light_, f, EcalMonitorTask_cff::func, castor_dqm_sourceclient_file_cfg::path, funct::pow(), mathSSE::sqrt(), hcalRecHitTable_cff::time, timeRes, timingQualityThreshold_, useMTDTiming_, useTimingAverage_, x, y, and z.

Referenced by produce().

399  {
400  for (auto &cand : resultCandidates) {
401  float beta = 1;
402  float time = 0.f;
403  float invTimeErr = 0.f;
404  float timeErr = -1.f;
405 
406  for (const auto &tr : cand.tracksters()) {
407  if (tr->timeError() > 0) {
408  const auto invTimeESq = pow(tr->timeError(), -2);
409  const auto x = tr->barycenter().X();
410  const auto y = tr->barycenter().Y();
411  const auto z = tr->barycenter().Z();
412  auto path = std::sqrt(x * x + y * y + z * z);
413  if (cand.trackPtr().get() != nullptr) {
414  const auto &trackIndex = cand.trackPtr().get() - (edm::Ptr<reco::Track>(track_h, 0)).get();
415  if (useMTDTiming_ and inputTimingView.timeErr()[trackIndex] > 0) {
416  const auto xMtd = inputTimingView.posInMTD_x()[trackIndex];
417  const auto yMtd = inputTimingView.posInMTD_y()[trackIndex];
418  const auto zMtd = inputTimingView.posInMTD_z()[trackIndex];
419 
420  beta = inputTimingView.beta()[trackIndex];
421  path = std::sqrt((x - xMtd) * (x - xMtd) + (y - yMtd) * (y - yMtd) + (z - zMtd) * (z - zMtd)) +
422  inputTimingView.pathLength()[trackIndex];
423  } else {
424  float pathLength = func(*(cand.trackPtr().get()), z);
425  if (pathLength) {
426  path = pathLength;
427  }
428  }
429  }
430  time += (tr->time() - path / (beta * c_light_)) * invTimeESq;
431  invTimeErr += invTimeESq;
432  }
433  }
434  if (invTimeErr > 0) {
435  time = time / invTimeErr;
436  // FIXME_ set a liminf of 0.02 ns on the ts error (based on residuals)
437  timeErr = sqrt(1.f / invTimeErr);
438  if (timeErr < timeRes)
439  timeErr = timeRes;
440  cand.setTime(time, timeErr);
441  }
442 
443  if (useMTDTiming_ and cand.charge()) {
444  // Check MTD timing availability
445  const auto &trackIndex = cand.trackPtr().get() - (edm::Ptr<reco::Track>(track_h, 0)).get();
446  const bool assocQuality = inputTimingView.MVAquality()[trackIndex] > timingQualityThreshold_;
447  if (assocQuality) {
448  const auto timeHGC = cand.time();
449  const auto timeEHGC = cand.timeError();
450  const auto timeMTD = inputTimingView.time0()[trackIndex];
451  const auto timeEMTD = inputTimingView.time0Err()[trackIndex];
452 
453  if (useTimingAverage_ && (timeEMTD > 0 && timeEHGC > 0)) {
454  // Compute weighted average between HGCAL and MTD timing
455  const auto invTimeESqHGC = pow(timeEHGC, -2);
456  const auto invTimeESqMTD = pow(timeEMTD, -2);
457  timeErr = 1.f / (invTimeESqHGC + invTimeESqMTD);
458  time = (timeHGC * invTimeESqHGC + timeMTD * invTimeESqMTD) * timeErr;
459  timeErr = sqrt(timeErr);
460  } else if (timeEMTD > 0) {
461  time = timeMTD;
462  timeErr = timeEMTD;
463  }
464  }
465  cand.setTime(time, timeErr);
466  cand.setMTDTime(inputTimingView.time()[trackIndex], inputTimingView.timeErr()[trackIndex]);
467  }
468  }
469 }
T sqrt(T t)
Definition: SSEVec.h:23
double f[11][100]
static constexpr float c_light_
static constexpr float timeRes
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ beginRun()

void TICLCandidateProducer::beginRun ( edm::Run const &  iEvent,
edm::EventSetup const &  es 
)
override

Definition at line 184 of file TICLCandidateProducer.cc.

References bfield_, bfield_token_, generalInterpretationAlgo_, relativeConstraints::geom, geometry_token_, edm::EventSetup::getHandle(), hdc_token_, hgcons_, edm::ESHandle< T >::product(), propagator_, propagator_token_, rhtools_, hgcal::RecHitTools::setGeometry(), trackingGeometry_, and trackingGeometry_token_.

184  {
185  edm::ESHandle<HGCalDDDConstants> hdc = es.getHandle(hdc_token_);
186  hgcons_ = hdc.product();
187 
190 
191  bfield_ = es.getHandle(bfield_token_);
192  propagator_ = es.getHandle(propagator_token_);
194 
196 };
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bfield_token_
edm::ESHandle< Propagator > propagator_
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagator_token_
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry_
T const * product() const
Definition: ESHandle.h:86
edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > hdc_token_
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:79
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > trackingGeometry_token_
const HGCalDDDConstants * hgcons_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometry_token_
std::unique_ptr< TICLInterpretationAlgoBase< reco::Track > > generalInterpretationAlgo_
edm::ESHandle< MagneticField > bfield_

◆ dumpCandidate()

void TICLCandidateProducer::dumpCandidate ( const TICLCandidate ) const
private

◆ fillDescriptions()

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

Definition at line 471 of file TICLCandidateProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addNode(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

471  {
473  edm::ParameterSetDescription interpretationDesc;
474  interpretationDesc.addNode(edm::PluginDescription<TICLGeneralInterpretationPluginFactory>("type", "General", true));
475  desc.add<edm::ParameterSetDescription>("interpretationDescPSet", interpretationDesc);
476  desc.add<std::vector<edm::InputTag>>("egamma_tracksters_collections", {edm::InputTag("ticlTracksterLinks")});
477  desc.add<std::vector<edm::InputTag>>("egamma_tracksterlinks_collections", {edm::InputTag("ticlTracksterLinks")});
478  desc.add<std::vector<edm::InputTag>>("general_tracksters_collections", {edm::InputTag("ticlTracksterLinks")});
479  desc.add<std::vector<edm::InputTag>>("general_tracksterlinks_collections", {edm::InputTag("ticlTracksterLinks")});
480  desc.add<std::vector<edm::InputTag>>("original_masks",
481  {edm::InputTag("hgcalMergeLayerClusters", "InitialLayerClustersMask")});
482  desc.add<edm::InputTag>("layer_clusters", edm::InputTag("hgcalMergeLayerClusters"));
483  desc.add<edm::InputTag>("layer_clustersTime", edm::InputTag("hgcalMergeLayerClusters", "timeLayerCluster"));
484  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
485  desc.add<edm::InputTag>("timingSoA", edm::InputTag("mtdSoA"));
486  desc.add<edm::InputTag>("muons", edm::InputTag("muons1stStep"));
487  desc.add<std::string>("detector", "HGCAL");
488  desc.add<std::string>("propagator", "PropagatorWithMaterial");
489  desc.add<bool>("useMTDTiming", true);
490  desc.add<bool>("useTimingAverage", true);
491  desc.add<double>("timingQualityThreshold", 0.5);
492  desc.add<std::string>("cutTk",
493  "1.48 < abs(eta) < 3.0 && pt > 1. && quality(\"highPurity\") && "
494  "hitPattern().numberOfLostHits(\"MISSING_OUTER_HITS\") < 5");
495  descriptions.add("ticlCandidateProducer", desc);
496 }
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void TICLCandidateProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 228 of file TICLCandidateProducer.cc.

References ticl::assignPCAtoTracksters(), assignTimeToCandidates(), bfield_, Disk::build(), clusters_token_, clustersTime_token_, cutTk_, filterTracks(), general_tracksterlinks_tokens_, general_tracksters_tokens_, generalInterpretationAlgo_, edm::Event::get(), edm::Event::getByToken(), hgcal::RecHitTools::getPositionLayer(), hgcons_, mps_fire::i, trajectoryStateTransform::innerFreeState(), trajectoryStateTransform::innerStateOnSurface(), input, inputTimingToken_, createfilelist::int, edm::Ref< C, T, F >::isNonnull(), dqmiolumiharvest::j, dqmdumpme::k, hgcal::RecHitTools::lastLayerEE(), hltEgammaHGCALIDVarsL1Seeded_cfi::layerClusters, eostools::move(), PFMuonAlgo::muAssocToTrack(), muons_token_, original_masks_tokens_, trajectoryStateTransform::outerFreeState(), trajectoryStateTransform::outerStateOnSurface(), edm::ESHandle< T >::product(), TrackCandidateProducer_cfi::propagator, propagator_, edm::Event::put(), HGCalDDDConstants::rangeR(), rhtools_, edm::second(), reco::LeafCandidate::setPdgId(), findQualityFiles::size, tkEnergyCut_, HLT_2024v13_cff::track, trackingGeometry_, DiMuonV_cfg::tracks, tracks_token_, useMTDTiming_, and z.

228  {
229  auto resultTracksters = std::make_unique<std::vector<Trackster>>();
230  auto resultTrackstersMerged = std::make_unique<std::vector<Trackster>>();
231  auto linkedResultTracksters = std::make_unique<std::vector<std::vector<unsigned int>>>();
232 
233  const auto &layerClusters = evt.get(clusters_token_);
234  const auto &layerClustersTimes = evt.get(clustersTime_token_);
236  evt.getByToken(muons_token_, muons_h);
237 
239  evt.getByToken(tracks_token_, tracks_h);
240  const auto &tracks = *tracks_h;
241 
242  edm::Handle<MtdHostCollection> inputTiming_h;
243  MtdHostCollection::ConstView inputTimingView;
244  if (useMTDTiming_) {
245  evt.getByToken(inputTimingToken_, inputTiming_h);
246  inputTimingView = (*inputTiming_h).const_view();
247  }
248 
249  auto const bFieldProd = bfield_.product();
251 
252  // loop over the original_masks_tokens_ and get the original masks collections and multiply them
253  // to get the global mask
254  std::vector<float> original_global_mask(layerClusters.size(), 1.f);
255  for (unsigned int i = 0; i < original_masks_tokens_.size(); ++i) {
256  const auto &tmp_mask = evt.get(original_masks_tokens_[i]);
257  for (unsigned int j = 0; j < tmp_mask.size(); ++j) {
258  original_global_mask[j] *= tmp_mask[j];
259  }
260  }
261 
262  auto resultMask = std::make_unique<std::vector<float>>(original_global_mask);
263 
264  std::vector<edm::Handle<std::vector<Trackster>>> general_tracksters_h(general_tracksters_tokens_.size());
265  MultiVectorManager<Trackster> generalTrackstersManager;
266  for (unsigned int i = 0; i < general_tracksters_tokens_.size(); ++i) {
267  evt.getByToken(general_tracksters_tokens_[i], general_tracksters_h[i]);
268  //Fill MultiVectorManager
269  generalTrackstersManager.addVector(*general_tracksters_h[i]);
270  }
271  //now get the general_tracksterlinks_tokens_
272  std::vector<edm::Handle<std::vector<std::vector<unsigned>>>> general_tracksterlinks_h(
274  std::vector<std::vector<unsigned>> generalTracksterLinksGlobalId;
275  for (unsigned int i = 0; i < general_tracksterlinks_tokens_.size(); ++i) {
276  evt.getByToken(general_tracksterlinks_tokens_[i], general_tracksterlinks_h[i]);
277  for (unsigned int j = 0; j < general_tracksterlinks_h[i]->size(); ++j) {
278  generalTracksterLinksGlobalId.emplace_back();
279  auto &links_vector = generalTracksterLinksGlobalId.back();
280  links_vector.resize((*general_tracksterlinks_h[i])[j].size());
281  for (unsigned int k = 0; k < links_vector.size(); ++k) {
282  links_vector[k] = generalTrackstersManager.getGlobalIndex(i, (*general_tracksterlinks_h[i])[j][k]);
283  }
284  }
285  }
286 
287  std::vector<bool> maskTracks;
288  maskTracks.resize(tracks.size());
289  filterTracks(tracks_h, muons_h, cutTk_, tkEnergyCut_, maskTracks);
290 
292  es,
294  layerClustersTimes,
295  generalTrackstersManager,
296  generalTracksterLinksGlobalId,
297  tracks_h,
298  maskTracks);
299 
300  auto resultCandidates = std::make_unique<std::vector<TICLCandidate>>();
301  std::vector<int> trackstersInTrackIndices(tracks.size(), -1);
302 
303  //TODO
304  //egammaInterpretationAlg_->makecandidates(inputGSF, inputTiming, *resultTrackstersMerged, trackstersInGSFTrackIndices)
305  // mask generalTracks associated to GSFTrack linked in egammaInterpretationAlgo_
306 
307  generalInterpretationAlgo_->makeCandidates(input, inputTiming_h, *resultTracksters, trackstersInTrackIndices);
308 
310  *resultTracksters, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z(), true);
311 
312  std::vector<bool> maskTracksters(resultTracksters->size(), true);
313  edm::OrphanHandle<std::vector<Trackster>> resultTracksters_h = evt.put(std::move(resultTracksters));
314  //create ChargedCandidates
315  for (size_t iTrack = 0; iTrack < tracks.size(); iTrack++) {
316  if (maskTracks[iTrack]) {
317  auto const tracksterId = trackstersInTrackIndices[iTrack];
318  auto trackPtr = edm::Ptr<reco::Track>(tracks_h, iTrack);
319  if (tracksterId != -1 and !maskTracksters.empty()) {
320  auto tracksterPtr = edm::Ptr<Trackster>(resultTracksters_h, tracksterId);
321  TICLCandidate chargedCandidate(trackPtr, tracksterPtr);
322  resultCandidates->push_back(chargedCandidate);
323  maskTracksters[tracksterId] = false;
324  } else {
325  //charged candidates track only
326  edm::Ptr<Trackster> tracksterPtr;
327  TICLCandidate chargedCandidate(trackPtr, tracksterPtr);
328  auto trackRef = edm::Ref<reco::TrackCollection>(tracks_h, iTrack);
329  const int muId = PFMuonAlgo::muAssocToTrack(trackRef, *muons_h);
330  const reco::MuonRef muonRef = reco::MuonRef(muons_h, muId);
331  if (muonRef.isNonnull() and muonRef->isGlobalMuon()) {
332  // create muon candidate
333  chargedCandidate.setPdgId(13 * trackPtr.get()->charge());
334  }
335  resultCandidates->push_back(chargedCandidate);
336  }
337  }
338  }
339 
340  //Neutral Candidate
341  for (size_t iTrackster = 0; iTrackster < maskTracksters.size(); iTrackster++) {
342  if (maskTracksters[iTrackster]) {
343  edm::Ptr<Trackster> tracksterPtr(resultTracksters_h, iTrackster);
344  edm::Ptr<reco::Track> trackPtr;
345  TICLCandidate neutralCandidate(trackPtr, tracksterPtr);
346  resultCandidates->push_back(neutralCandidate);
347  }
348  }
349 
350  auto getPathLength = [&](const reco::Track &track, float zVal) {
351  const auto &fts_inn = trajectoryStateTransform::innerFreeState(track, bFieldProd);
352  const auto &fts_out = trajectoryStateTransform::outerFreeState(track, bFieldProd);
353  const auto &surf_inn = trajectoryStateTransform::innerStateOnSurface(track, *trackingGeometry_, bFieldProd);
354  const auto &surf_out = trajectoryStateTransform::outerStateOnSurface(track, *trackingGeometry_, bFieldProd);
355 
356  Basic3DVector<float> pos(track.referencePoint());
357  Basic3DVector<float> mom(track.momentum());
358  FreeTrajectoryState stateAtBeamspot{GlobalPoint(pos), GlobalVector(mom), track.charge(), bFieldProd};
359 
360  float pathlength = propagator->propagateWithPath(stateAtBeamspot, surf_inn.surface()).second;
361 
362  if (pathlength) {
363  const auto &t_inn_out = propagator->propagateWithPath(fts_inn, surf_out.surface());
364 
365  if (t_inn_out.first.isValid()) {
366  pathlength += t_inn_out.second;
367 
368  std::pair<float, float> rMinMax = hgcons_->rangeR(zVal, true);
369 
370  int iSide = int(track.eta() > 0);
371  float zSide = (iSide == 0) ? (-1. * zVal) : zVal;
372  const auto &disk = std::make_unique<GeomDet>(
373  Disk::build(Disk::PositionType(0, 0, zSide),
375  SimpleDiskBounds(rMinMax.first, rMinMax.second, zSide - 0.5, zSide + 0.5))
376  .get());
377  const auto &tsos = propagator->propagateWithPath(fts_out, disk->surface());
378 
379  if (tsos.first.isValid()) {
380  pathlength += tsos.second;
381  return pathlength;
382  }
383  }
384  }
385  edm::LogWarning("TICLCandidateProducer")
386  << "Not able to use the track to compute the path length. A straight line will be used instead.";
387  return 0.f;
388  };
389 
390  assignTimeToCandidates(*resultCandidates, tracks_h, inputTimingView, getPathLength);
391 
392  evt.put(std::move(resultCandidates));
393 }
size
Write out results.
static DiskPointer build(Args &&... args)
Definition: BoundDisk.h:38
static int muAssocToTrack(const reco::TrackRef &trackref, const reco::MuonCollection &muons)
Definition: PFMuonAlgo.cc:479
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:344
const StringCutObjectSelector< reco::Track > cutTk_
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
void assignTimeToCandidates(std::vector< TICLCandidate > &resultCandidates, edm::Handle< std::vector< reco::Track >> track_h, MtdHostCollection::ConstView &inputTimingView, F func) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
const edm::EDGetTokenT< std::vector< reco::Track > > tracks_token_
static std::string const input
Definition: EdmProvDump.cc:50
edm::ESHandle< Propagator > propagator_
U second(std::pair< T, U > const &p)
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry_
T const * product() const
Definition: ESHandle.h:86
edm::Ref< MuonCollection > MuonRef
presistent reference to a Muon
Definition: MuonFwd.h:13
std::vector< edm::EDGetTokenT< std::vector< Trackster > > > general_tracksters_tokens_
std::pair< double, double > rangeR(double z, bool reco) const
typename Layout::ConstView ConstView
GlobalPoint getPositionLayer(int layer, bool nose=false) const
Definition: RecHitTools.cc:152
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
const HGCalDDDConstants * hgcons_
std::vector< edm::EDGetTokenT< std::vector< std::vector< unsigned > > > > general_tracksterlinks_tokens_
void assignPCAtoTracksters(std::vector< Trackster > &, const std::vector< reco::CaloCluster > &, const edm::ValueMap< std::pair< float, float >> &, double, bool computeLocalTime=false, bool energyWeight=true)
edm::EDGetTokenT< MtdHostCollection > inputTimingToken_
std::vector< edm::EDGetTokenT< std::vector< float > > > original_masks_tokens_
std::unique_ptr< TICLInterpretationAlgoBase< reco::Track > > generalInterpretationAlgo_
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
Log< level::Warning, false > LogWarning
edm::ESHandle< MagneticField > bfield_
FreeTrajectoryState outerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
void filterTracks(edm::Handle< std::vector< reco::Track >> tkH, const edm::Handle< std::vector< reco::Muon >> &muons_h, const StringCutObjectSelector< reco::Track > cutTk_, const float tkEnergyCut_, std::vector< bool > &maskTracks)
const edm::EDGetTokenT< std::vector< reco::Muon > > muons_token_
def move(src, dest)
Definition: eostools.py:511
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:76
Global3DVector GlobalVector
Definition: GlobalVector.h:10
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)

Member Data Documentation

◆ bfield_

edm::ESHandle<MagneticField> TICLCandidateProducer::bfield_
private

Definition at line 109 of file TICLCandidateProducer.cc.

Referenced by beginRun(), and produce().

◆ bfield_token_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> TICLCandidateProducer::bfield_token_
private

Definition at line 97 of file TICLCandidateProducer.cc.

Referenced by beginRun().

◆ c_light_

constexpr float TICLCandidateProducer::c_light_ = CLHEP::c_light * CLHEP::ns / CLHEP::cm
staticprivate

Definition at line 112 of file TICLCandidateProducer.cc.

Referenced by assignTimeToCandidates().

◆ clusters_token_

const edm::EDGetTokenT<std::vector<reco::CaloCluster> > TICLCandidateProducer::clusters_token_
private

Definition at line 83 of file TICLCandidateProducer.cc.

Referenced by produce().

◆ clustersTime_token_

const edm::EDGetTokenT<edm::ValueMap<std::pair<float, float> > > TICLCandidateProducer::clustersTime_token_
private

Definition at line 84 of file TICLCandidateProducer.cc.

Referenced by produce().

◆ cutTk_

const StringCutObjectSelector<reco::Track> TICLCandidateProducer::cutTk_
private

Definition at line 107 of file TICLCandidateProducer.cc.

Referenced by produce().

◆ detector_

const std::string TICLCandidateProducer::detector_
private

Definition at line 98 of file TICLCandidateProducer.cc.

Referenced by TICLCandidateProducer().

◆ egamma_tracksterlinks_tokens_

std::vector<edm::EDGetTokenT<std::vector<std::vector<unsigned> > > > TICLCandidateProducer::egamma_tracksterlinks_tokens_
private

Definition at line 78 of file TICLCandidateProducer.cc.

Referenced by TICLCandidateProducer().

◆ egamma_tracksters_tokens_

std::vector<edm::EDGetTokenT<std::vector<Trackster> > > TICLCandidateProducer::egamma_tracksters_tokens_
private

Definition at line 77 of file TICLCandidateProducer.cc.

Referenced by TICLCandidateProducer().

◆ general_tracksterlinks_tokens_

std::vector<edm::EDGetTokenT<std::vector<std::vector<unsigned> > > > TICLCandidateProducer::general_tracksterlinks_tokens_
private

Definition at line 81 of file TICLCandidateProducer.cc.

Referenced by produce(), and TICLCandidateProducer().

◆ general_tracksters_tokens_

std::vector<edm::EDGetTokenT<std::vector<Trackster> > > TICLCandidateProducer::general_tracksters_tokens_
private

Definition at line 80 of file TICLCandidateProducer.cc.

Referenced by produce(), and TICLCandidateProducer().

◆ generalInterpretationAlgo_

std::unique_ptr<TICLInterpretationAlgoBase<reco::Track> > TICLCandidateProducer::generalInterpretationAlgo_
private

Definition at line 76 of file TICLCandidateProducer.cc.

Referenced by beginRun(), produce(), and TICLCandidateProducer().

◆ geometry_token_

const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> TICLCandidateProducer::geometry_token_
private

Definition at line 95 of file TICLCandidateProducer.cc.

Referenced by beginRun().

◆ hdc_token_

edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord> TICLCandidateProducer::hdc_token_
private

Definition at line 108 of file TICLCandidateProducer.cc.

Referenced by beginRun(), and TICLCandidateProducer().

◆ hgcons_

const HGCalDDDConstants* TICLCandidateProducer::hgcons_
private

Definition at line 104 of file TICLCandidateProducer.cc.

Referenced by beginRun(), and produce().

◆ initializeGeometry_

std::once_flag TICLCandidateProducer::initializeGeometry_
private

Definition at line 103 of file TICLCandidateProducer.cc.

◆ inputTimingToken_

edm::EDGetTokenT<MtdHostCollection> TICLCandidateProducer::inputTimingToken_
private

Definition at line 89 of file TICLCandidateProducer.cc.

Referenced by produce(), and TICLCandidateProducer().

◆ muons_token_

const edm::EDGetTokenT<std::vector<reco::Muon> > TICLCandidateProducer::muons_token_
private

Definition at line 91 of file TICLCandidateProducer.cc.

Referenced by produce().

◆ original_masks_tokens_

std::vector<edm::EDGetTokenT<std::vector<float> > > TICLCandidateProducer::original_masks_tokens_
private

Definition at line 86 of file TICLCandidateProducer.cc.

Referenced by produce(), and TICLCandidateProducer().

◆ propagator_

edm::ESHandle<Propagator> TICLCandidateProducer::propagator_
private

Definition at line 110 of file TICLCandidateProducer.cc.

Referenced by beginRun(), and produce().

◆ propagator_token_

const edm::ESGetToken<Propagator, TrackingComponentsRecord> TICLCandidateProducer::propagator_token_
private

Definition at line 100 of file TICLCandidateProducer.cc.

Referenced by beginRun().

◆ propName_

const std::string TICLCandidateProducer::propName_
private

Definition at line 99 of file TICLCandidateProducer.cc.

◆ rhtools_

hgcal::RecHitTools TICLCandidateProducer::rhtools_
private

Definition at line 105 of file TICLCandidateProducer.cc.

Referenced by beginRun(), and produce().

◆ timeRes

constexpr float TICLCandidateProducer::timeRes = 0.02f
staticprivate

Definition at line 113 of file TICLCandidateProducer.cc.

Referenced by assignTimeToCandidates().

◆ timingQualityThreshold_

const float TICLCandidateProducer::timingQualityThreshold_
private

Definition at line 94 of file TICLCandidateProducer.cc.

Referenced by assignTimeToCandidates().

◆ tkEnergyCut_

const float TICLCandidateProducer::tkEnergyCut_ = 2.0f
private

Definition at line 106 of file TICLCandidateProducer.cc.

Referenced by produce().

◆ trackingGeometry_

edm::ESHandle<GlobalTrackingGeometry> TICLCandidateProducer::trackingGeometry_
private

Definition at line 111 of file TICLCandidateProducer.cc.

Referenced by beginRun(), and produce().

◆ trackingGeometry_token_

const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> TICLCandidateProducer::trackingGeometry_token_
private

Definition at line 101 of file TICLCandidateProducer.cc.

Referenced by beginRun().

◆ tracks_token_

const edm::EDGetTokenT<std::vector<reco::Track> > TICLCandidateProducer::tracks_token_
private

Definition at line 88 of file TICLCandidateProducer.cc.

Referenced by produce().

◆ useMTDTiming_

const bool TICLCandidateProducer::useMTDTiming_
private

Definition at line 92 of file TICLCandidateProducer.cc.

Referenced by assignTimeToCandidates(), produce(), and TICLCandidateProducer().

◆ useTimingAverage_

const bool TICLCandidateProducer::useTimingAverage_
private

Definition at line 93 of file TICLCandidateProducer.cc.

Referenced by assignTimeToCandidates().