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  muons_token_(consumes<std::vector<reco::Muon>>(ps.getParameter<edm::InputTag>("muons"))),
122  useMTDTiming_(ps.getParameter<bool>("useMTDTiming")),
123  useTimingAverage_(ps.getParameter<bool>("useTimingAverage")),
124  timingQualityThreshold_(ps.getParameter<double>("timingQualityThreshold")),
125  geometry_token_(esConsumes<CaloGeometry, CaloGeometryRecord, edm::Transition::BeginRun>()),
126  bfield_token_(esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>()),
127  detector_(ps.getParameter<std::string>("detector")),
128  propName_(ps.getParameter<std::string>("propagator")),
130  esConsumes<Propagator, TrackingComponentsRecord, edm::Transition::BeginRun>(edm::ESInputTag("", propName_))),
132  esConsumes<GlobalTrackingGeometry, GlobalTrackingGeometryRecord, edm::Transition::BeginRun>()),
133  cutTk_(ps.getParameter<std::string>("cutTk")) {
134  // These are the CLUE3DEM Tracksters put in the event by the TracksterLinksProducer with the superclustering algorithm
135  for (auto const &tag : ps.getParameter<std::vector<edm::InputTag>>("egamma_tracksters_collections")) {
136  egamma_tracksters_tokens_.emplace_back(consumes<std::vector<Trackster>>(tag));
137  }
138 
139  // These are the links put in the event by the TracksterLinksProducer with the superclustering algorithm
140  for (auto const &tag : ps.getParameter<std::vector<edm::InputTag>>("egamma_tracksterlinks_collections")) {
141  egamma_tracksterlinks_tokens_.emplace_back(consumes<std::vector<std::vector<unsigned int>>>(tag));
142  }
143 
144  //make sure that the number of tracksters collections and tracksterlinks collections is the same
146 
147  // Loop over the edm::VInputTag and append the token to general_tracksters_tokens_
148  // These, instead, are the tracksters already merged by the TrackstersLinksProducer
149  for (auto const &tag : ps.getParameter<std::vector<edm::InputTag>>("general_tracksters_collections")) {
150  general_tracksters_tokens_.emplace_back(consumes<std::vector<Trackster>>(tag));
151  }
152 
153  for (auto const &tag : ps.getParameter<std::vector<edm::InputTag>>("general_tracksterlinks_collections")) {
154  general_tracksterlinks_tokens_.emplace_back(consumes<std::vector<std::vector<unsigned int>>>(tag));
155  }
156 
157  //make sure that the number of tracksters collections and tracksterlinks collections is the same
159 
160  //Loop over the edm::VInputTag of masks and append the token to original_masks_tokens_
161  for (auto const &tag : ps.getParameter<std::vector<edm::InputTag>>("original_masks")) {
162  original_masks_tokens_.emplace_back(consumes<std::vector<float>>(tag));
163  }
164 
165  std::string detectorName_ = (detector_ == "HFNose") ? "HGCalHFNoseSensitive" : "HGCalEESensitive";
166  hdc_token_ =
167  esConsumes<HGCalDDDConstants, IdealGeometryRecord, edm::Transition::BeginRun>(edm::ESInputTag("", detectorName_));
168  if (useMTDTiming_) {
169  inputTimingToken_ = consumes<MtdHostCollection>(ps.getParameter<edm::InputTag>("timingSoA"));
170  }
171 
172  produces<std::vector<TICLCandidate>>();
173 
174  // New trackster collection after linking
175  produces<std::vector<Trackster>>();
176 
177  auto interpretationPSet = ps.getParameter<edm::ParameterSet>("interpretationDescPSet");
178  auto algoType = interpretationPSet.getParameter<std::string>("type");
180  TICLGeneralInterpretationPluginFactory::get()->create(algoType, interpretationPSet, consumesCollector());
181 }
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 402 of file TICLCandidateProducer.cc.

References HLT_2024v14_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().

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

183  {
184  edm::ESHandle<HGCalDDDConstants> hdc = es.getHandle(hdc_token_);
185  hgcons_ = hdc.product();
186 
189 
190  bfield_ = es.getHandle(bfield_token_);
191  propagator_ = es.getHandle(propagator_token_);
193 
195 };
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 477 of file TICLCandidateProducer.cc.

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

477  {
479  edm::ParameterSetDescription interpretationDesc;
480  interpretationDesc.addNode(edm::PluginDescription<TICLGeneralInterpretationPluginFactory>("type", "General", true));
481  desc.add<edm::ParameterSetDescription>("interpretationDescPSet", interpretationDesc);
482  desc.add<std::vector<edm::InputTag>>("egamma_tracksters_collections", {edm::InputTag("ticlTracksterLinks")});
483  desc.add<std::vector<edm::InputTag>>("egamma_tracksterlinks_collections", {edm::InputTag("ticlTracksterLinks")});
484  desc.add<std::vector<edm::InputTag>>("general_tracksters_collections", {edm::InputTag("ticlTracksterLinks")});
485  desc.add<std::vector<edm::InputTag>>("general_tracksterlinks_collections", {edm::InputTag("ticlTracksterLinks")});
486  desc.add<std::vector<edm::InputTag>>("original_masks",
487  {edm::InputTag("hgcalMergeLayerClusters", "InitialLayerClustersMask")});
488  desc.add<edm::InputTag>("layer_clusters", edm::InputTag("hgcalMergeLayerClusters"));
489  desc.add<edm::InputTag>("layer_clustersTime", edm::InputTag("hgcalMergeLayerClusters", "timeLayerCluster"));
490  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
491  desc.add<edm::InputTag>("timingSoA", edm::InputTag("mtdSoA"));
492  desc.add<edm::InputTag>("muons", edm::InputTag("muons1stStep"));
493  desc.add<std::string>("detector", "HGCAL");
494  desc.add<std::string>("propagator", "PropagatorWithMaterial");
495  desc.add<bool>("useMTDTiming", true);
496  desc.add<bool>("useTimingAverage", true);
497  desc.add<double>("timingQualityThreshold", 0.5);
498  desc.add<std::string>("cutTk",
499  "1.48 < abs(eta) < 3.0 && pt > 1. && quality(\"highPurity\") && "
500  "hitPattern().numberOfLostHits(\"MISSING_OUTER_HITS\") < 5");
501  descriptions.add("ticlCandidateProducer", desc);
502 }
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 227 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, LogDebug, 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_2024v14_cff::track, trackingGeometry_, DiMuonV_cfg::tracks, tracks_token_, useMTDTiming_, and z.

227  {
228  auto resultTracksters = std::make_unique<std::vector<Trackster>>();
229  auto resultTrackstersMerged = std::make_unique<std::vector<Trackster>>();
230  auto linkedResultTracksters = std::make_unique<std::vector<std::vector<unsigned int>>>();
231 
232  const auto &layerClusters = evt.get(clusters_token_);
233  const auto &layerClustersTimes = evt.get(clustersTime_token_);
235  evt.getByToken(muons_token_, muons_h);
236 
238  evt.getByToken(tracks_token_, tracks_h);
239  const auto &tracks = *tracks_h;
240 
241  edm::Handle<MtdHostCollection> inputTiming_h;
242  MtdHostCollection::ConstView inputTimingView;
243  if (useMTDTiming_) {
244  evt.getByToken(inputTimingToken_, inputTiming_h);
245  inputTimingView = (*inputTiming_h).const_view();
246  }
247 
248  auto const bFieldProd = bfield_.product();
250 
251  // loop over the original_masks_tokens_ and get the original masks collections and multiply them
252  // to get the global mask
253  std::vector<float> original_global_mask(layerClusters.size(), 1.f);
254  for (unsigned int i = 0; i < original_masks_tokens_.size(); ++i) {
255  const auto &tmp_mask = evt.get(original_masks_tokens_[i]);
256  for (unsigned int j = 0; j < tmp_mask.size(); ++j) {
257  original_global_mask[j] *= tmp_mask[j];
258  }
259  }
260 
261  auto resultMask = std::make_unique<std::vector<float>>(original_global_mask);
262 
263  std::vector<edm::Handle<std::vector<Trackster>>> general_tracksters_h(general_tracksters_tokens_.size());
264  MultiVectorManager<Trackster> generalTrackstersManager;
265  for (unsigned int i = 0; i < general_tracksters_tokens_.size(); ++i) {
266  evt.getByToken(general_tracksters_tokens_[i], general_tracksters_h[i]);
267  //Fill MultiVectorManager
268  generalTrackstersManager.addVector(*general_tracksters_h[i]);
269  }
270  //now get the general_tracksterlinks_tokens_
271  std::vector<edm::Handle<std::vector<std::vector<unsigned>>>> general_tracksterlinks_h(
273  std::vector<std::vector<unsigned>> generalTracksterLinksGlobalId;
274  for (unsigned int i = 0; i < general_tracksterlinks_tokens_.size(); ++i) {
275  evt.getByToken(general_tracksterlinks_tokens_[i], general_tracksterlinks_h[i]);
276  for (unsigned int j = 0; j < general_tracksterlinks_h[i]->size(); ++j) {
277  generalTracksterLinksGlobalId.emplace_back();
278  auto &links_vector = generalTracksterLinksGlobalId.back();
279  links_vector.resize((*general_tracksterlinks_h[i])[j].size());
280  for (unsigned int k = 0; k < links_vector.size(); ++k) {
281  links_vector[k] = generalTrackstersManager.getGlobalIndex(i, (*general_tracksterlinks_h[i])[j][k]);
282  }
283  }
284  }
285 
286  std::vector<bool> maskTracks;
287  maskTracks.resize(tracks.size());
288  filterTracks(tracks_h, muons_h, cutTk_, tkEnergyCut_, maskTracks);
289 
291  es,
293  layerClustersTimes,
294  generalTrackstersManager,
295  generalTracksterLinksGlobalId,
296  tracks_h,
297  maskTracks);
298 
299  auto resultCandidates = std::make_unique<std::vector<TICLCandidate>>();
300  std::vector<int> trackstersInTrackIndices(tracks.size(), -1);
301 
302  //TODO
303  //egammaInterpretationAlg_->makecandidates(inputGSF, inputTiming, *resultTrackstersMerged, trackstersInGSFTrackIndices)
304  // mask generalTracks associated to GSFTrack linked in egammaInterpretationAlgo_
305 
306  generalInterpretationAlgo_->makeCandidates(input, inputTiming_h, *resultTracksters, trackstersInTrackIndices);
307 
308  assignPCAtoTracksters(*resultTracksters,
310  layerClustersTimes,
312  rhtools_,
313  true);
314 
315  std::vector<bool> maskTracksters(resultTracksters->size(), true);
316  edm::OrphanHandle<std::vector<Trackster>> resultTracksters_h = evt.put(std::move(resultTracksters));
317  //create ChargedCandidates
318  for (size_t iTrack = 0; iTrack < tracks.size(); iTrack++) {
319  if (maskTracks[iTrack]) {
320  auto const tracksterId = trackstersInTrackIndices[iTrack];
321  auto trackPtr = edm::Ptr<reco::Track>(tracks_h, iTrack);
322  if (tracksterId != -1 and !maskTracksters.empty()) {
323  auto tracksterPtr = edm::Ptr<Trackster>(resultTracksters_h, tracksterId);
324  TICLCandidate chargedCandidate(trackPtr, tracksterPtr);
325  resultCandidates->push_back(chargedCandidate);
326  maskTracksters[tracksterId] = false;
327  } else {
328  //charged candidates track only
329  edm::Ptr<Trackster> tracksterPtr;
330  TICLCandidate chargedCandidate(trackPtr, tracksterPtr);
331  auto trackRef = edm::Ref<reco::TrackCollection>(tracks_h, iTrack);
332  const int muId = PFMuonAlgo::muAssocToTrack(trackRef, *muons_h);
333  const reco::MuonRef muonRef = reco::MuonRef(muons_h, muId);
334  if (muonRef.isNonnull() and muonRef->isGlobalMuon()) {
335  // create muon candidate
336  chargedCandidate.setPdgId(13 * trackPtr.get()->charge());
337  }
338  resultCandidates->push_back(chargedCandidate);
339  }
340  }
341  }
342 
343  //Neutral Candidate
344  for (size_t iTrackster = 0; iTrackster < maskTracksters.size(); iTrackster++) {
345  if (maskTracksters[iTrackster]) {
346  edm::Ptr<Trackster> tracksterPtr(resultTracksters_h, iTrackster);
347  edm::Ptr<reco::Track> trackPtr;
348  TICLCandidate neutralCandidate(trackPtr, tracksterPtr);
349  resultCandidates->push_back(neutralCandidate);
350  }
351  }
352 
353  auto getPathLength =
354  [&](const reco::Track &track, float zVal) {
355  const auto &fts_inn = trajectoryStateTransform::innerFreeState(track, bFieldProd);
356  const auto &fts_out = trajectoryStateTransform::outerFreeState(track, bFieldProd);
357  const auto &surf_inn = trajectoryStateTransform::innerStateOnSurface(track, *trackingGeometry_, bFieldProd);
358  const auto &surf_out = trajectoryStateTransform::outerStateOnSurface(track, *trackingGeometry_, bFieldProd);
359 
360  Basic3DVector<float> pos(track.referencePoint());
361  Basic3DVector<float> mom(track.momentum());
362  FreeTrajectoryState stateAtBeamspot{GlobalPoint(pos), GlobalVector(mom), track.charge(), bFieldProd};
363 
364  float pathlength = propagator->propagateWithPath(stateAtBeamspot, surf_inn.surface()).second;
365 
366  if (pathlength) {
367  const auto &t_inn_out = propagator->propagateWithPath(fts_inn, surf_out.surface());
368 
369  if (t_inn_out.first.isValid()) {
370  pathlength += t_inn_out.second;
371 
372  std::pair<float, float> rMinMax = hgcons_->rangeR(zVal, true);
373 
374  int iSide = int(track.eta() > 0);
375  float zSide = (iSide == 0) ? (-1. * zVal) : zVal;
376  const auto &disk = std::make_unique<GeomDet>(
377  Disk::build(Disk::PositionType(0, 0, zSide),
379  SimpleDiskBounds(rMinMax.first, rMinMax.second, zSide - 0.5, zSide + 0.5))
380  .get());
381  const auto &tsos = propagator->propagateWithPath(fts_out, disk->surface());
382 
383  if (tsos.first.isValid()) {
384  pathlength += tsos.second;
385  return pathlength;
386  }
387  }
388  }
389 #ifdef EDM_ML_DEBUG
390  LogDebug("TICLCandidateProducer")
391  << "Not able to use the track to compute the path length. A straight line will be used instead.";
392 #endif
393  return 0.f;
394  };
395 
396  assignTimeToCandidates(*resultCandidates, tracks_h, inputTimingView, getPathLength);
397 
398  evt.put(std::move(resultCandidates));
399 }
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
void assignPCAtoTracksters(std::vector< Trackster > &tracksters, const std::vector< reco::CaloCluster > &layerClusters, const edm::ValueMap< std::pair< float, float >> &layerClustersTime, double z_limit_em, hgcal::RecHitTools const &rhTools, bool computeLocalTime=false, bool energyWeight=true, bool clean=false, int minLayer=10, int maxLayer=10)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:526
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_
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)
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)
#define LogDebug(id)

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().