CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TrackProducerWithSCAssociation Class Reference

#include <TrackProducerWithSCAssociation.h>

Inheritance diagram for TrackProducerWithSCAssociation:
TrackProducerBase< reco::Track > edm::stream::EDProducer<> AlgoProductTraits< reco::Track >

Public Member Functions

std::vector< reco::TransientTrackgetTransient (edm::Event &, const edm::EventSetup &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 Method where the procduction take place. To be implemented in concrete classes. More...
 
 TrackProducerWithSCAssociation (const edm::ParameterSet &iConfig)
 
- Public Member Functions inherited from TrackProducerBase< reco::Track >
const edm::ParameterSetgetConf () const
 
virtual void getFromES (const edm::EventSetup &, edm::ESHandle< TrackerGeometry > &, edm::ESHandle< MagneticField > &, edm::ESHandle< TrajectoryFitter > &, edm::ESHandle< Propagator > &, edm::ESHandle< MeasurementTracker > &, edm::ESHandle< TransientTrackingRecHitBuilder > &)
 Get needed services from the Event Setup. More...
 
virtual void getFromEvt (edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
 Get TrackCandidateCollection from the Event (needed by TrackProducer) More...
 
virtual void getFromEvt (edm::Event &, edm::Handle< TrackView > &, reco::BeamSpot &)
 Get TrackCollection from the Event (needed by TrackRefitter) More...
 
void setAlias (std::string alias)
 set the aliases of produced collections More...
 
void setClusterRemovalInfo (const edm::InputTag &clusterRemovalInfo)
 Sets the information on cluster removal, and turns it on. More...
 
void setConf (const edm::ParameterSet &conf)
 Set parameter set. More...
 
void setSecondHitPattern (Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTrackerEvent *measTk, const TrackerTopology *ttopo)
 
void setSrc (const edm::EDGetToken &src, const edm::EDGetTokenT< reco::BeamSpot > &bsSrc, const edm::EDGetTokenT< MeasurementTrackerEvent > &mteSrc)
 set label of source collection More...
 
 TrackProducerBase (bool trajectoryInEvent=false)
 Constructor. More...
 
virtual ~TrackProducerBase ()(false)
 Destructor. More...
 
- 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
 

Private Member Functions

void putInEvt (edm::Event &evt, const Propagator *thePropagator, const MeasurementTracker *theMeasTk, std::unique_ptr< TrackingRecHitCollection > selHits, std::unique_ptr< reco::TrackCollection > selTracks, std::unique_ptr< reco::TrackExtraCollection > selTrackExtras, std::unique_ptr< std::vector< Trajectory >> selTrajectories, AlgoProductCollection &algoResults, TransientTrackingRecHitBuilder const *hitBuilder, const TrackerTopology *ttopo)
 

Private Attributes

edm::EDGetTokenT< reco::TrackCandidateCaloClusterPtrAssociationassoc_token
 
std::string conversionTrackCandidateProducer_
 
edm::EDGetTokenT< MeasurementTrackerEventmeasurementTrkToken_
 
std::string myname_
 
bool myTrajectoryInEvent_
 
edm::OrphanHandle< reco::TrackCollectionrTracks_
 
TrackProducerAlgorithm< reco::TracktheAlgo
 
std::string trackCSuperClusterAssociationCollection_
 
std::string trackSuperClusterAssociationCollection_
 
bool validTrackCandidateSCAssociationInput_
 

Additional Inherited Members

- Public Types inherited from TrackProducerBase< reco::Track >
using AlgoProductCollection = typename Base::AlgoProductCollection
 
using Base = AlgoProductTraits< reco::Track >
 
using TrackCollection = typename Base::TrackCollection
 
using TrackView = typename Base::TrackView
 
- Public Types inherited from AlgoProductTraits< reco::Track >
using AlgoProductCollection = std::vector< AlgoProduct >
 
using TrackCollection = std::vector< reco::Track >
 
using TrackView = edm::View< reco::Track >
 
- 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
 
- Protected Attributes inherited from TrackProducerBase< reco::Track >
std::string alias_
 
edm::EDGetTokenT< reco::BeamSpotbsSrc_
 
edm::InputTag clusterRemovalInfo_
 
edm::ParameterSet conf_
 
edm::EDGetTokenT< MeasurementTrackerEventmteSrc_
 
bool rekeyClusterRefs_
 
edm::OrphanHandle< TrackCollectionrTracks_
 
edm::EDGetToken src_
 
edm::ESHandle< NavigationSchooltheSchool
 
bool trajectoryInEvent_
 

Detailed Description

Author
Nancy Marinelli, U. of Notre Dame, US Modified version of TrackProducer by Giuseppe Cerati to have super cluster - conversion track association

Definition at line 19 of file TrackProducerWithSCAssociation.h.

Constructor & Destructor Documentation

TrackProducerWithSCAssociation::TrackProducerWithSCAssociation ( const edm::ParameterSet iConfig)
explicit

Definition at line 20 of file TrackProducerWithSCAssociation.cc.

References TrackProducerBase< reco::Track >::alias_, assoc_token, conversionTrackCandidateProducer_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), HLT_2018_cff::InputTag, measurementTrkToken_, myname_, myTrajectoryInEvent_, TrackProducerBase< reco::Track >::setAlias(), TrackProducerBase< reco::Track >::setClusterRemovalInfo(), TrackProducerBase< reco::Track >::setConf(), TrackProducerBase< reco::Track >::setSrc(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, trackCSuperClusterAssociationCollection_, and trackSuperClusterAssociationCollection_.

21  : TrackProducerBase<reco::Track>(iConfig.getParameter<bool>("TrajectoryInEvent")), theAlgo(iConfig) {
22  setConf(iConfig);
23  setSrc(consumes<TrackCandidateCollection>(iConfig.getParameter<edm::InputTag>("src")),
24  consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot")),
25  consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>("MeasurementTrackerEvent")));
26  setAlias(iConfig.getParameter<std::string>("@module_label"));
27 
28  if (iConfig.exists("clusterRemovalInfo")) {
29  edm::InputTag tag = iConfig.getParameter<edm::InputTag>("clusterRemovalInfo");
30  if (!(tag == edm::InputTag())) {
32  }
33  }
34 
35  myname_ = iConfig.getParameter<std::string>("ComponentName");
37  trackCSuperClusterAssociationCollection_ = iConfig.getParameter<std::string>("trackCandidateSCAssociationCollection");
38  trackSuperClusterAssociationCollection_ = iConfig.getParameter<std::string>("recoTrackSCAssociationCollection");
39  myTrajectoryInEvent_ = iConfig.getParameter<bool>("TrajectoryInEvent");
40 
41  assoc_token = consumes<reco::TrackCandidateCaloClusterPtrAssociation>(
42  edm::InputTag(conversionTrackCandidateProducer_, trackCSuperClusterAssociationCollection_));
43  measurementTrkToken_ = consumes<MeasurementTrackerEvent>(
44  edm::InputTag("MeasurementTrackerEvent")); //hardcoded because the original was and no time to fix (sigh)
45 
46  //register your products
47  produces<reco::TrackCollection>().setBranchAlias(alias_ + "Tracks");
48  produces<reco::TrackExtraCollection>().setBranchAlias(alias_ + "TrackExtras");
49  produces<TrackingRecHitCollection>().setBranchAlias(alias_ + "RecHits");
50  produces<std::vector<Trajectory>>();
51  produces<TrajTrackAssociationCollection>();
52  // produces< reco::TrackSuperClusterAssociationCollection > (trackSuperClusterAssociationCollection_ );
53  produces<reco::TrackCaloClusterPtrAssociation>(trackSuperClusterAssociationCollection_);
54 }
T getParameter(std::string const &) const
edm::EDGetTokenT< MeasurementTrackerEvent > measurementTrkToken_
bool exists(std::string const &parameterName) const
checks if a parameter exists
void setClusterRemovalInfo(const edm::InputTag &clusterRemovalInfo)
Sets the information on cluster removal, and turns it on.
edm::EDGetTokenT< reco::TrackCandidateCaloClusterPtrAssociation > assoc_token
void setAlias(std::string alias)
set the aliases of produced collections
void setConf(const edm::ParameterSet &conf)
Set parameter set.
TrackProducerAlgorithm< reco::Track > theAlgo
void setSrc(const edm::EDGetToken &src, const edm::EDGetTokenT< reco::BeamSpot > &bsSrc, const edm::EDGetTokenT< MeasurementTrackerEvent > &mteSrc)
set label of source collection

Member Function Documentation

std::vector< reco::TransientTrack > TrackProducerWithSCAssociation::getTransient ( edm::Event theEvent,
const edm::EventSetup setup 
)

Definition at line 210 of file TrackProducerWithSCAssociation.cc.

References MillePedeFileConverter_cfg::e, TrackProducerBase< reco::Track >::getFromES(), TrackProducerBase< reco::Track >::getFromEvt(), edm::EventBase::id(), Propagator::magneticField(), dumpMFGeometry_cfg::prod, edm::ESHandle< T >::product(), TrackProducerAlgorithm< T >::runWithCandidate(), and theAlgo.

211  {
212  edm::LogInfo("TrackProducerWithSCAssociation") << "Analyzing event number: " << theEvent.id() << "\n";
213  //
214  // create empty output collections
215  //
216  std::vector<reco::TransientTrack> ttks;
217 
218  //
219  //declare and get stuff to be retrieved from ES
220  //
224  edm::ESHandle<Propagator> thePropagator;
227  getFromES(setup, theG, theMF, theFitter, thePropagator, theMeasTk, theBuilder);
228 
229  //
230  //declare and get TrackColection to be retrieved from the event
231  //
232  AlgoProductCollection algoResults;
233  reco::BeamSpot bs;
234 
235  try {
237  getFromEvt(theEvent, theTCCollection, bs);
238 
239  //
240  //run the algorithm
241  //
242  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation run the algorithm" << "\n";
244  theMF.product(),
245  *theTCCollection,
246  theFitter.product(),
247  thePropagator.product(),
248  theBuilder.product(),
249  bs,
250  algoResults);
251 
252  } catch (cms::Exception& e) {
253  edm::LogInfo("TrackProducerWithSCAssociation") << "cms::Exception caught!!!"
254  << "\n"
255  << e << "\n";
256  }
257 
258  for (auto& prod : algoResults) {
259  ttks.emplace_back(*prod.track, thePropagator.product()->magneticField());
260  }
261 
262  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation end" << "\n";
263 
264  return ttks;
265 }
virtual void getFromEvt(edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
Get TrackCandidateCollection from the Event (needed by TrackProducer)
typename Base::AlgoProductCollection AlgoProductCollection
virtual const MagneticField * magneticField() const =0
TrackProducerAlgorithm< reco::Track > theAlgo
edm::EventID id() const
Definition: EventBase.h:59
void runWithCandidate(const TrackingGeometry *, const MagneticField *, const TrackCandidateCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
Run the Final Fit taking TrackCandidates as input.
T const * product() const
Definition: ESHandle.h:86
virtual void getFromES(const edm::EventSetup &, edm::ESHandle< TrackerGeometry > &, edm::ESHandle< MagneticField > &, edm::ESHandle< TrajectoryFitter > &, edm::ESHandle< Propagator > &, edm::ESHandle< MeasurementTracker > &, edm::ESHandle< TransientTrackingRecHitBuilder > &)
Get needed services from the Event Setup.
void TrackProducerWithSCAssociation::produce ( edm::Event ,
const edm::EventSetup  
)
overridevirtual

Method where the procduction take place. To be implemented in concrete classes.

Implements TrackProducerBase< reco::Track >.

Definition at line 56 of file TrackProducerWithSCAssociation.cc.

References assoc_token, TransientTrackingRecHitBuilder::build(), TrackProducerAlgorithm< T >::buildTrack(), generateEDF::cont, PTrajectoryStateOnDet::detId(), MillePedeFileConverter_cfg::e, edm::ValueMap< T >::empty(), edm::HandleBase::failedToGet(), benchmark_cfg::fc, edm::helper::Filler< Map >::fill(), trigObjTnPSource_cfi::filler, edm::EventSetup::get(), edm::Event::getByToken(), TrackProducerBase< reco::Track >::getFromES(), TrackProducerBase< reco::Track >::getFromEvt(), hfClusterShapes_cfi::hits, mps_fire::i, edm::helper::Filler< Map >::insert(), edm::HandleBase::isValid(), eostools::move(), ndof, convertSQLiteXML::ok, edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::Event::put(), putInEvt(), TrackCandidate::recHits(), rTracks_, TrackCandidate::seed(), SurveyInfoScenario_cff::seed, TrackCandidate::seedRef(), theAlgo, trackCSuperClusterAssociationCollection_, trackSuperClusterAssociationCollection_, TrackCandidate::trajectoryStateOnDet(), trajectoryStateTransform::transientState(), and validTrackCandidateSCAssociationInput_.

56  {
57  //edm::LogInfo("TrackProducerWithSCAssociation") << "Analyzing event number: " << theEvent.id() << "\n";
58 
59  //LogDebug("TrackProducerWithSCAssociation") << "Analyzing event number: " << theEvent.id() << "\n";
60  // std::cout << " TrackProducerWithSCAssociation Analyzing event number: " << theEvent.id() << "\n";
61 
62  //
63  // create empty output collections
64  //
65  auto outputRHColl = std::make_unique<TrackingRecHitCollection>();
66  auto outputTColl = std::make_unique<reco::TrackCollection>();
67  auto outputTEColl = std::make_unique<reco::TrackExtraCollection>();
68  auto outputTrajectoryColl = std::make_unique<std::vector<Trajectory>>();
69  // Reco Track - Super Cluster Association
70  auto scTrkAssoc_p = std::make_unique<reco::TrackCaloClusterPtrAssociation>();
71 
72  //
73  //declare and get stuff to be retrieved from ES
74  //
78  edm::ESHandle<Propagator> thePropagator;
81  getFromES(setup, theG, theMF, theFitter, thePropagator, theMeasTk, theBuilder);
82 
84  setup.get<TrackerTopologyRcd>().get(httopo);
85  const TrackerTopology* ttopo = httopo.product();
86 
87  //
88  //declare and get TrackColection to be retrieved from the event
93  theEvent.getByToken(assoc_token, trkCandidateSCAssocHandle);
94  if (!trkCandidateSCAssocHandle.isValid()) {
95  // std::cout << "Error! Can't get the product "<<trackCSuperClusterAssociationCollection_.c_str() << " but keep running. Empty collection will be produced " << "\n";
96  edm::LogError("TrackProducerWithSCAssociation")
97  << "Error! Can't get the product " << trackCSuperClusterAssociationCollection_.c_str()
98  << " but keep running. Empty collection will be produced "
99  << "\n";
101  }
102  reco::TrackCandidateCaloClusterPtrAssociation scTrkCandAssCollection = *(trkCandidateSCAssocHandle.product());
103  if (scTrkCandAssCollection.empty())
105 
106  std::vector<int> tccLocations;
107  AlgoProductCollection algoResults;
108  reco::BeamSpot bs;
109 
110  getFromEvt(theEvent, theTCCollection, bs);
111 
112  if (theTCCollection.failedToGet()) {
113  edm::LogError("TrackProducerWithSCAssociation")
114  << "TrackProducerWithSCAssociation could not get the TrackCandidateCollection.";
115  } else {
116  //
117  //run the algorithm
118  //
119  // LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation run the algorithm" << "\n";
120  // theAlgo.runWithCandidate(theG.product(), theMF.product(), *theTCCollection,
121  // theFitter.product(), thePropagator.product(), theBuilder.product(), algoResults);
122  // we have to copy this method from the algo in order to get the association track-seed
123  // this is ugly temporary code that should be replaced!!!!!
124  // start of copied code ======================================================
125 
126  // std::cout << "TrackProducerWithSCAssociation Number of TrackCandidates: " << theTCCollection->size() << "\n";
127  try {
128  int cont = 0;
129  int tcc = 0;
130 
131  for (TrackCandidateCollection::const_iterator i = theTCCollection->begin(); i != theTCCollection->end(); i++) {
132  const TrackCandidate* theTC = &(*i);
134  const TrackCandidate::range& recHitVec = theTC->recHits();
135  const TrajectorySeed& seed = theTC->seed();
136 
137  //convert PTrajectoryStateOnDet to TrajectoryStateOnSurface
138 
139  DetId detId(state.detId());
141  state, &(theG.product()->idToDet(detId)->surface()), theMF.product());
142 
143  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation Initial TSOS\n" << theTSOS << "\n";
144 
145  //convert the TrackingRecHit vector to a TransientTrackingRecHit vector
146  //meanwhile computes the number of degrees of freedom
148 
149  float ndof = 0;
150 
151  for (edm::OwnVector<TrackingRecHit>::const_iterator i = recHitVec.first; i != recHitVec.second; i++) {
152  hits.push_back(theBuilder.product()->build(&(*i)));
153  }
154 
155  //build Track
156  // LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation going to buildTrack"<< "\n";
157  FitterCloner fc(theFitter.product(), theBuilder.product());
158  bool ok = theAlgo.buildTrack(
159  fc.fitter.get(), thePropagator.product(), algoResults, hits, theTSOS, seed, ndof, bs, theTC->seedRef());
160  // LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation buildTrack result: " << ok << "\n";
161  if (ok) {
162  cont++;
163  tccLocations.push_back(tcc);
164  }
165  tcc++;
166  }
167  edm::LogInfo("TrackProducerWithSCAssociation") << "Number of Tracks found: " << cont << "\n";
168  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation Number of Tracks found: " << cont << "\n";
169  // end of copied code ======================================================
170 
171  } catch (cms::Exception& e) {
172  edm::LogInfo("TrackProducerWithSCAssociation") << "cms::Exception caught!!!"
173  << "\n"
174  << e << "\n";
175  }
176  //
177  //put everything in the event
178  // we copy putInEvt to get OrphanHandle filled...
179  putInEvt(theEvent,
180  thePropagator.product(),
181  theMeasTk.product(),
182  std::move(outputRHColl),
183  std::move(outputTColl),
184  std::move(outputTEColl),
185  std::move(outputTrajectoryColl),
186  algoResults,
187  theBuilder.product(),
188  ttopo);
189 
190  // now construct associationmap and put it in the event
192  int itrack = 0;
193  std::vector<edm::Ptr<reco::CaloCluster>> caloPtrVec;
194  for (AlgoProductCollection::iterator i = algoResults.begin(); i != algoResults.end(); i++) {
195  edm::Ref<TrackCandidateCollection> trackCRef(theTCCollection, tccLocations[itrack]);
196  const edm::Ptr<reco::CaloCluster>& aClus = (*trkCandidateSCAssocHandle)[trackCRef];
197  caloPtrVec.push_back(aClus);
198  itrack++;
199  }
200 
202  filler.insert(rTracks_, caloPtrVec.begin(), caloPtrVec.end());
203  filler.fill();
204  }
205 
206  theEvent.put(std::move(scTrkAssoc_p), trackSuperClusterAssociationCollection_);
207  }
208 }
bool empty() const
Definition: ValueMap.h:158
virtual void getFromEvt(edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
Get TrackCandidateCollection from the Event (needed by TrackProducer)
range recHits() const
edm::OrphanHandle< reco::TrackCollection > rTracks_
typename Base::AlgoProductCollection AlgoProductCollection
TrajectorySeed const & seed() const
std::vector< ConstRecHitPointer > RecHitContainer
edm::EDGetTokenT< reco::TrackCandidateCaloClusterPtrAssociation > assoc_token
bool buildTrack(const TrajectoryFitter *, const Propagator *, AlgoProductCollection &, TransientTrackingRecHit::RecHitContainer &, TrajectoryStateOnSurface &, const TrajectorySeed &, float, const reco::BeamSpot &, SeedRef seedRef=SeedRef(), int qualityMask=0, signed char nLoops=0)
Construct Tracks to be put in the event.
PTrajectoryStateOnDet const & trajectoryStateOnDet() const
unsigned int detId() const
bool isValid() const
Definition: HandleBase.h:70
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
TrackProducerAlgorithm< reco::Track > theAlgo
bool failedToGet() const
Definition: HandleBase.h:72
Definition: DetId.h:17
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
T const * product() const
Definition: Handle.h:69
std::pair< const_iterator, const_iterator > range
void putInEvt(edm::Event &evt, const Propagator *thePropagator, const MeasurementTracker *theMeasTk, std::unique_ptr< TrackingRecHitCollection > selHits, std::unique_ptr< reco::TrackCollection > selTracks, std::unique_ptr< reco::TrackExtraCollection > selTrackExtras, std::unique_ptr< std::vector< Trajectory >> selTrajectories, AlgoProductCollection &algoResults, TransientTrackingRecHitBuilder const *hitBuilder, const TrackerTopology *ttopo)
T const * product() const
Definition: ESHandle.h:86
edm::RefToBase< TrajectorySeed > seedRef() const
def move(src, dest)
Definition: eostools.py:511
cont
load Luminosity info ##
Definition: generateEDF.py:629
virtual void getFromES(const edm::EventSetup &, edm::ESHandle< TrackerGeometry > &, edm::ESHandle< MagneticField > &, edm::ESHandle< TrajectoryFitter > &, edm::ESHandle< Propagator > &, edm::ESHandle< MeasurementTracker > &, edm::ESHandle< TransientTrackingRecHitBuilder > &)
Get needed services from the Event Setup.
void TrackProducerWithSCAssociation::putInEvt ( edm::Event evt,
const Propagator thePropagator,
const MeasurementTracker theMeasTk,
std::unique_ptr< TrackingRecHitCollection selHits,
std::unique_ptr< reco::TrackCollection selTracks,
std::unique_ptr< reco::TrackExtraCollection selTrackExtras,
std::unique_ptr< std::vector< Trajectory >>  selTrajectories,
AlgoProductCollection algoResults,
TransientTrackingRecHitBuilder const *  hitBuilder,
const TrackerTopology ttopo 
)
private

Definition at line 269 of file TrackProducerWithSCAssociation.cc.

References alongMomentum, reco::TrackBase::appendHitPattern(), TrajectoryStateOnSurface::curvilinearError(), Trajectory::direction(), Trajectory::firstMeasurement(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), TrajectoryStateOnSurface::globalParameters(), mps_fire::i, training_settings::idx, edm::ESHandleBase::isValid(), Trajectory::lastMeasurement(), measurementTrkToken_, GlobalTrajectoryParameters::momentum(), eostools::move(), myTrajectoryInEvent_, AlCaHLTBitMon_ParallelJobs::p, GlobalTrajectoryParameters::position(), edm::Event::put(), TrajectoryMeasurement::recHit(), rTracks_, Trajectory::seedRef(), reco::Track::setExtra(), reco::TrackExtraBase::setHits(), TrackProducerBase< reco::Track >::setSecondHitPattern(), reco::TrackExtraBase::setTrajParams(), OrderedSet::t, TrackProducerBase< reco::Track >::theSchool, HLT_2018_cff::track, TrackProducerBase< reco::Track >::trajectoryInEvent_, TrajectoryMeasurement::updatedState(), findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

278  {
281 
284  edm::Ref<std::vector<Trajectory>>::key_type iTjRef = 0;
285  std::map<unsigned int, unsigned int> tjTkMap;
286 
287  for (auto& i : algoResults) {
288  Trajectory* theTraj = i.trajectory;
289  if (myTrajectoryInEvent_) {
290  selTrajectories->push_back(*theTraj);
291  iTjRef++;
292  }
293 
294  reco::Track* theTrack = i.track;
295  PropagationDirection seedDir = i.pDir;
296 
297  //LogDebug("TrackProducer") << "In KfTrackProducerBase::putInEvt - seedDir=" << seedDir;
298 
299  reco::Track t = *theTrack;
300  selTracks->push_back(t);
301  iTkRef++;
302 
303  // Store indices in local map (starts at 0)
304  if (trajectoryInEvent_)
305  tjTkMap[iTjRef - 1] = iTkRef - 1;
306 
307  //sets the outermost and innermost TSOSs
308 
309  TrajectoryStateOnSurface outertsos;
310  TrajectoryStateOnSurface innertsos;
311  unsigned int innerId, outerId;
312 
313  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
314  // This is consistent with innermost and outermost labels only for tracks from LHC collision
315  if (theTraj->direction() == alongMomentum) {
316  outertsos = theTraj->lastMeasurement().updatedState();
317  innertsos = theTraj->firstMeasurement().updatedState();
318  outerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
319  innerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
320  } else {
321  outertsos = theTraj->firstMeasurement().updatedState();
322  innertsos = theTraj->lastMeasurement().updatedState();
323  outerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
324  innerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
325  }
326  // ---
327  //build the TrackExtra
328  GlobalPoint v = outertsos.globalParameters().position();
329  GlobalVector p = outertsos.globalParameters().momentum();
330  math::XYZVector outmom(p.x(), p.y(), p.z());
331  math::XYZPoint outpos(v.x(), v.y(), v.z());
332  v = innertsos.globalParameters().position();
333  p = innertsos.globalParameters().momentum();
334  math::XYZVector inmom(p.x(), p.y(), p.z());
335  math::XYZPoint inpos(v.x(), v.y(), v.z());
336 
337  reco::TrackExtraRef teref = reco::TrackExtraRef(rTrackExtras, idx++);
338  reco::Track& track = selTracks->back();
339  track.setExtra(teref);
340 
341  //======= I want to set the second hitPattern here =============
342  if (theSchool.isValid()) {
345  setSecondHitPattern(theTraj, track, thePropagator, &*mte, ttopo);
346  }
347  //==============================================================
348 
349  selTrackExtras->push_back(reco::TrackExtra(outpos,
350  outmom,
351  true,
352  inpos,
353  inmom,
354  true,
355  outertsos.curvilinearError(),
356  outerId,
357  innertsos.curvilinearError(),
358  innerId,
359  seedDir,
360  theTraj->seedRef()));
361 
362  reco::TrackExtra& tx = selTrackExtras->back();
363  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
364  // This is consistent with innermost and outermost labels only for tracks from LHC collisions
365  reco::TrackExtra::TrajParams trajParams;
367  Traj2TrackHits t2t;
368  auto ih = selHits->size();
369  t2t(*theTraj, *selHits, trajParams, chi2s);
370  auto ie = selHits->size();
371  tx.setHits(rHits, ih, ie - ih);
372  tx.setTrajParams(std::move(trajParams), std::move(chi2s));
373  for (; ih < ie; ++ih) {
374  auto const& hit = (*selHits)[ih];
375  track.appendHitPattern(hit, *ttopo);
376  }
377  // ----
378 
379  delete theTrack;
380  delete theTraj;
381  }
382 
383  //LogTrace("TrackingRegressionTest") << "========== TrackProducer Info ===================";
384  //LogDebug("TrackProducerWithSCAssociation") << "number of finalTracks: " << selTracks->size() << std::endl;
385  //for (reco::TrackCollection::const_iterator it = selTracks->begin(); it != selTracks->end(); it++) {
386  //LogDebug("TrackProducerWithSCAssociation") << "track's n valid and invalid hit, chi2, pt : "
387  // << it->found() << " , "
388  // << it->lost() <<" , "
389  // << it->normalizedChi2() << " , "
390  // << it->pt() << std::endl;
391  // }
392  //LogTrace("TrackingRegressionTest") << "=================================================";
393 
394  rTracks_ = evt.put(std::move(selTracks));
395 
396  evt.put(std::move(selTrackExtras));
397  evt.put(std::move(selHits));
398 
399  if (myTrajectoryInEvent_) {
400  edm::OrphanHandle<std::vector<Trajectory>> rTrajs = evt.put(std::move(selTrajectories));
401 
402  // Now Create traj<->tracks association map
403  auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(rTrajs, rTracks_);
404  for (std::map<unsigned int, unsigned int>::iterator i = tjTkMap.begin(); i != tjTkMap.end(); i++) {
405  edm::Ref<std::vector<Trajectory>> trajRef(rTrajs, (*i).first);
406  edm::Ref<reco::TrackCollection> tkRef(rTracks_, (*i).second);
407  trajTrackMap->insert(edm::Ref<std::vector<Trajectory>>(rTrajs, (*i).first),
409  }
410  evt.put(std::move(trajTrackMap));
411  }
412 }
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
edm::EDGetTokenT< MeasurementTrackerEvent > measurementTrkToken_
ConstRecHitPointer const & recHit() const
std::vector< unsigned char > Chi2sFive
edm::OrphanHandle< reco::TrackCollection > rTracks_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
const CurvilinearTrajectoryError & curvilinearError() const
T y() const
Definition: PV3DBase.h:60
void setSecondHitPattern(Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTrackerEvent *measTk, const TrackerTopology *ttopo)
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
PropagationDirection
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
std::vector< LocalTrajectoryParameters > TrajParams
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
T z() const
Definition: PV3DBase.h:61
edm::RefToBase< TrajectorySeed > seedRef(void) const
Definition: Trajectory.h:303
RefProd< PROD > getRefBeforePut()
Definition: Event.h:156
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
void setExtra(const TrackExtraRef &ref)
set reference to "extra" object
Definition: Track.h:136
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
const GlobalTrajectoryParameters & globalParameters() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool appendHitPattern(const TrackingRecHit &hit, const TrackerTopology &ttopo)
append a single hit to the HitPattern
Definition: TrackBase.h:489
edm::ESHandle< NavigationSchool > theSchool
TrajectoryStateOnSurface const & updatedState() const
bool isValid() const
Definition: ESHandle.h:44
T x() const
Definition: PV3DBase.h:59
def move(src, dest)
Definition: eostools.py:511
void setTrajParams(TrajParams tmps, Chi2sFive chi2s)

Member Data Documentation

edm::EDGetTokenT<reco::TrackCandidateCaloClusterPtrAssociation> TrackProducerWithSCAssociation::assoc_token
private

Definition at line 33 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and TrackProducerWithSCAssociation().

std::string TrackProducerWithSCAssociation::conversionTrackCandidateProducer_
private

Definition at line 30 of file TrackProducerWithSCAssociation.h.

Referenced by TrackProducerWithSCAssociation().

edm::EDGetTokenT<MeasurementTrackerEvent> TrackProducerWithSCAssociation::measurementTrkToken_
private

Definition at line 35 of file TrackProducerWithSCAssociation.h.

Referenced by putInEvt(), and TrackProducerWithSCAssociation().

std::string TrackProducerWithSCAssociation::myname_
private

Definition at line 28 of file TrackProducerWithSCAssociation.h.

Referenced by TrackProducerWithSCAssociation().

bool TrackProducerWithSCAssociation::myTrajectoryInEvent_
private

Definition at line 36 of file TrackProducerWithSCAssociation.h.

Referenced by putInEvt(), and TrackProducerWithSCAssociation().

edm::OrphanHandle<reco::TrackCollection> TrackProducerWithSCAssociation::rTracks_
private

Definition at line 34 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and putInEvt().

TrackProducerAlgorithm<reco::Track> TrackProducerWithSCAssociation::theAlgo
private

Definition at line 29 of file TrackProducerWithSCAssociation.h.

Referenced by getTransient(), and produce().

std::string TrackProducerWithSCAssociation::trackCSuperClusterAssociationCollection_
private

Definition at line 31 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and TrackProducerWithSCAssociation().

std::string TrackProducerWithSCAssociation::trackSuperClusterAssociationCollection_
private

Definition at line 32 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and TrackProducerWithSCAssociation().

bool TrackProducerWithSCAssociation::validTrackCandidateSCAssociationInput_
private

Definition at line 37 of file TrackProducerWithSCAssociation.h.

Referenced by produce().