CMS 3D CMS Logo

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

#include <RecoTracker/NuclearSeedGenerator/interface/NuclearTrackCorrector.h>

Inheritance diagram for NuclearTrackCorrector:
edm::stream::EDProducer<>

Public Types

using AlgoProductCollection = TrackProducerAlgorithm< reco::Track >::AlgoProductCollection
 
typedef TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
 
typedef edm::Ref< TrackCandidateCollectionTrackCandidateRef
 
typedef edm::Ref< TrajectoryCollectionTrajectoryRef
 
typedef edm::RefVector< TrajectorySeedCollectionTrajectorySeedRefVector
 
- 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
 

Public Member Functions

 NuclearTrackCorrector (const edm::ParameterSet &)
 
 ~NuclearTrackCorrector () 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
 

Private Member Functions

TrajectoryStateOnSurface getInitialState (const reco::Track *theT, TransientTrackingRecHit::RecHitContainer &hits, const TrackingGeometry *theG, const MagneticField *theMF)
 Calculate the inital state to be used to buil the track. More...
 
reco::TrackExtra getNewTrackExtra (const AlgoProductCollection &algoresults)
 get a new TrackExtra from an AlgoProductCollection More...
 
bool getTrackFromTrajectory (const Trajectory &newTraj, const TrajectoryRef &initialTrajRef, AlgoProductCollection &algoResults)
 Get the refitted track from the Trajectory. More...
 
bool newTrajNeeded (Trajectory &newtrajectory, const TrajectoryRef &trajRef, const reco::NuclearInteraction &ni)
 check if the trajectory has to be refitted and get the new trajectory More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void swap_map (const edm::Handle< TrajectoryCollection > &trajColl, std::map< reco::TrackRef, edm::Ref< TrajectoryCollection > > &result)
 

Private Attributes

std::vector< std::pair< unsigned int, unsigned int > > Indice_Map
 
int int_Input_Hit_Distance
 
int KeepOnlyCorrectedTracks
 
const TrajTrackAssociationCollectionm_TrajToTrackCollection
 
std::string str_Input_NuclearInteraction
 
std::string str_Input_Trajectory
 
TrackProducerAlgorithm< reco::Track > * theAlgo
 
edm::ESHandle< TrajectoryFittertheFitter
 
edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::RecordtheFitterToken
 
edm::ESHandle< TrackerGeometrytheG
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtheGToken
 
TransientInitialStateEstimatortheInitialState
 
edm::ESHandle< MagneticFieldtheMF
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordtheMFToken
 
edm::ESHandle< PropagatorthePropagator
 
edm::ESGetToken< Propagator, TrackingComponentsRecordthePropagatorToken
 
int verbosity
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 67 of file NuclearTrackCorrector.h.

Member Typedef Documentation

◆ AlgoProductCollection

Definition at line 74 of file NuclearTrackCorrector.h.

◆ ConstRecHitContainer

Definition at line 72 of file NuclearTrackCorrector.h.

◆ TrackCandidateRef

Definition at line 71 of file NuclearTrackCorrector.h.

◆ TrajectoryRef

Definition at line 70 of file NuclearTrackCorrector.h.

◆ TrajectorySeedRefVector

Definition at line 69 of file NuclearTrackCorrector.h.

Constructor & Destructor Documentation

◆ NuclearTrackCorrector()

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

Definition at line 34 of file NuclearTrackCorrector.cc.

References deDxTools::esConsumes(), edm::ParameterSet::getParameter(), KeepOnlyCorrectedTracks, HLT_2024v14_cff::propagatorName, str_Input_NuclearInteraction, str_Input_Trajectory, AlCaHLTBitMon_QueryRunRegistry::string, theAlgo, theFitterToken, theGToken, theMFToken, thePropagatorToken, and verbosity.

34  : theInitialState(nullptr) {
35  str_Input_Trajectory = iConfig.getParameter<std::string>("InputTrajectory");
36  str_Input_NuclearInteraction = iConfig.getParameter<std::string>("InputNuclearInteraction");
37  verbosity = iConfig.getParameter<int>("Verbosity");
38  KeepOnlyCorrectedTracks = iConfig.getParameter<bool>("KeepOnlyCorrectedTracks");
39 
41 
42  produces<TrajectoryCollection>();
43  produces<TrajectoryToTrajectoryMap>();
44 
45  produces<reco::TrackExtraCollection>();
46  produces<reco::TrackCollection>();
47  produces<TrackToTrajectoryMap>();
48 
49  produces<TrackToTrackMap>();
50 
53  std::string fitterName = iConfig.getParameter<std::string>("Fitter");
54  theFitterToken = esConsumes(edm::ESInputTag("", fitterName));
55  std::string propagatorName = iConfig.getParameter<std::string>("Propagator");
57 }
edm::ESGetToken< Propagator, TrackingComponentsRecord > thePropagatorToken
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
TransientInitialStateEstimator * theInitialState
edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > theFitterToken
TrackProducerAlgorithm< reco::Track > * theAlgo
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > theGToken
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theMFToken
std::string str_Input_NuclearInteraction

◆ ~NuclearTrackCorrector()

NuclearTrackCorrector::~NuclearTrackCorrector ( )
override

Definition at line 59 of file NuclearTrackCorrector.cc.

59 {}

Member Function Documentation

◆ getInitialState()

TrajectoryStateOnSurface NuclearTrackCorrector::getInitialState ( const reco::Track theT,
TransientTrackingRecHit::RecHitContainer hits,
const TrackingGeometry theG,
const MagneticField theMF 
)
private

Calculate the inital state to be used to buil the track.

Definition at line 305 of file NuclearTrackCorrector.cc.

References TrajectoryStateOnSurface::globalPosition(), hfClusterShapes_cfi::hits, trajectoryStateTransform::innerStateOnSurface(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), mag2(), trajectoryStateTransform::outerStateOnSurface(), TrajectoryStateOnSurface::rescaleError(), TrajectoryStateOnSurface::surface(), theG, and theMF.

Referenced by getTrackFromTrajectory().

308  {
309  TrajectoryStateOnSurface theInitialStateForRefitting;
310  //the starting state is the state closest to the first hit along seedDirection.
311 
312  //avoiding to use transientTrack, it should be faster;
315  TrajectoryStateOnSurface initialStateFromTrack =
316  ((innerStateFromTrack.globalPosition() - hits.front()->globalPosition()).mag2() <
317  (outerStateFromTrack.globalPosition() - hits.front()->globalPosition()).mag2())
318  ? innerStateFromTrack
319  : outerStateFromTrack;
320 
321  // error is rescaled, but correlation are kept.
322  initialStateFromTrack.rescaleError(100);
323  theInitialStateForRefitting = TrajectoryStateOnSurface(initialStateFromTrack.localParameters(),
324  initialStateFromTrack.localError(),
325  initialStateFromTrack.surface(),
326  theMF);
327  return theInitialStateForRefitting;
328 }
const LocalTrajectoryError & localError() const
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)
edm::ESHandle< MagneticField > theMF
const LocalTrajectoryParameters & localParameters() const
const SurfaceType & surface() const
GlobalPoint globalPosition() const
edm::ESHandle< TrackerGeometry > theG
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)

◆ getNewTrackExtra()

reco::TrackExtra NuclearTrackCorrector::getNewTrackExtra ( const AlgoProductCollection algoresults)
private

get a new TrackExtra from an AlgoProductCollection

Definition at line 264 of file NuclearTrackCorrector.cc.

References alongMomentum, TrajectoryStateOnSurface::curvilinearError(), Trajectory::direction(), Trajectory::firstMeasurement(), TrajectoryStateOnSurface::globalParameters(), Trajectory::lastMeasurement(), GlobalTrajectoryParameters::momentum(), AlCaHLTBitMon_ParallelJobs::p, GlobalTrajectoryParameters::position(), TrajectoryMeasurement::recHit(), TrajectoryMeasurement::updatedState(), and findQualityFiles::v.

Referenced by produce().

264  {
265  Trajectory* theTraj = algoResults[0].trajectory;
266  PropagationDirection seedDir = algoResults[0].pDir;
267 
268  TrajectoryStateOnSurface outertsos;
269  TrajectoryStateOnSurface innertsos;
270  unsigned int innerId, outerId;
271  if (theTraj->direction() == alongMomentum) {
272  outertsos = theTraj->lastMeasurement().updatedState();
273  innertsos = theTraj->firstMeasurement().updatedState();
274  outerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
275  innerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
276  } else {
277  outertsos = theTraj->firstMeasurement().updatedState();
278  innertsos = theTraj->lastMeasurement().updatedState();
279  outerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
280  innerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
281  }
282 
283  GlobalPoint v = outertsos.globalParameters().position();
284  GlobalVector p = outertsos.globalParameters().momentum();
285  math::XYZVector outmom(p.x(), p.y(), p.z());
286  math::XYZPoint outpos(v.x(), v.y(), v.z());
287  v = innertsos.globalParameters().position();
288  p = innertsos.globalParameters().momentum();
289  math::XYZVector inmom(p.x(), p.y(), p.z());
290  math::XYZPoint inpos(v.x(), v.y(), v.z());
291 
292  return reco::TrackExtra(outpos,
293  outmom,
294  true,
295  inpos,
296  inmom,
297  true,
298  outertsos.curvilinearError(),
299  outerId,
300  innertsos.curvilinearError(),
301  innerId,
302  seedDir);
303 }
const GlobalTrajectoryParameters & globalParameters() const
PropagationDirection
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
const CurvilinearTrajectoryError & curvilinearError() 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
TrajectoryStateOnSurface const & updatedState() const
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
ConstRecHitPointer const & recHit() const

◆ getTrackFromTrajectory()

bool NuclearTrackCorrector::getTrackFromTrajectory ( const Trajectory newTraj,
const TrajectoryRef initialTrajRef,
AlgoProductCollection algoResults 
)
private

Get the refitted track from the Trajectory.

Definition at line 221 of file NuclearTrackCorrector.cc.

References cms::cuda::bs, TrackProducerAlgorithm< T >::buildTrack(), getInitialState(), h, hfClusterShapes_cfi::hits, sistrip::SpyUtilities::isValid(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, LogDebug, m_TrajToTrackCollection, PixelVertexMonitor_cff::ndof, edm::ESHandle< T >::product(), theAlgo, theFitter, theG, theMF, and thePropagator.

Referenced by produce().

223  {
224  const Trajectory* it = &newTraj;
225 
227  it->validRecHits(hits);
228 
229  float ndof = 0;
230  for (unsigned int h = 0; h < hits.size(); h++) {
231  if (hits[h]->isValid()) {
232  ndof = ndof + hits[h]->dimension() * hits[h]->weight();
233  } else {
234  LogDebug("NuclearSeedGenerator") << " HIT IS INVALID ???";
235  }
236  }
237 
238  ndof = ndof - 5;
239  reco::TrackRef theT = m_TrajToTrackCollection->operator[](initialTrajRef);
240  LogDebug("NuclearSeedGenerator") << " TrackCorrector - number of valid hits" << hits.size() << "\n"
241  << " - number of hits from Track " << theT->recHitsSize() << "\n"
242  << " - number of valid hits from initial track "
243  << theT->numberOfValidHits();
244 
245  if (hits.size() > 1) {
246  TrajectoryStateOnSurface theInitialStateForRefitting =
247  getInitialState(&(*theT), hits, theG.product(), theMF.product());
248 
252  algoResults,
253  hits,
254  theInitialStateForRefitting,
255  it->seed(),
256  ndof,
257  bs,
258  theT->seedRef());
259  }
260 
261  return false;
262 }
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
edm::ESHandle< MagneticField > theMF
std::vector< ConstRecHitPointer > RecHitContainer
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.
T const * product() const
Definition: ESHandle.h:86
edm::ESHandle< TrackerGeometry > theG
TrackProducerAlgorithm< reco::Track > * theAlgo
edm::ESHandle< Propagator > thePropagator
edm::ESHandle< TrajectoryFitter > theFitter
const TrajTrackAssociationCollection * m_TrajToTrackCollection
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
TrajectoryStateOnSurface getInitialState(const reco::Track *theT, TransientTrackingRecHit::RecHitContainer &hits, const TrackingGeometry *theG, const MagneticField *theMF)
Calculate the inital state to be used to buil the track.
#define LogDebug(id)

◆ newTrajNeeded()

bool NuclearTrackCorrector::newTrajNeeded ( Trajectory newtrajectory,
const TrajectoryRef trajRef,
const reco::NuclearInteraction ni 
)
private

check if the trajectory has to be refitted and get the new trajectory

Definition at line 180 of file NuclearTrackCorrector.cc.

References alongMomentum, TrackerGeometry::idToDet(), createfilelist::int, LogDebug, visualization-live-secondInstance_cfg::m, PV3DBase< T, PVType, FrameType >::mag(), reco::Vertex::position(), Trajectory::push(), rpcPointValidation_cfi::recHit, mathSSE::sqrt(), GeomDet::surface(), theG, Surface::toGlobal(), verbosity, and reco::NuclearInteraction::vertex().

Referenced by produce().

182  {
183  bool needNewTraj = false;
184  reco::Vertex::Point vtx_pos = ni.vertex().position();
185  double vtx_pos_mag = sqrt(vtx_pos.X() * vtx_pos.X() + vtx_pos.Y() * vtx_pos.Y() + vtx_pos.Z() * vtx_pos.Z());
186  if (verbosity >= 2)
187  printf("Nuclear Interaction pos = %f\n", vtx_pos_mag);
188 
189  newtrajectory = Trajectory(trajRef->seed(), alongMomentum);
190 
191  // Look all the Hits of the trajectory and keep only Hits before seeds
192  Trajectory::DataContainer Measurements = trajRef->measurements();
193  if (verbosity >= 2)
194  LogDebug("NuclearTrackCorrector") << "Size of Measurements = " << Measurements.size();
195 
196  for (unsigned int m = Measurements.size() - 1; m != (unsigned int)-1; m--) {
197  if (!Measurements[m].recHit()->isValid())
198  continue;
199  GlobalPoint hit_pos = theG->idToDet(Measurements[m].recHit()->geographicalId())
200  ->surface()
201  .toGlobal(Measurements[m].recHit()->localPosition());
202 
203  if (verbosity >= 2)
204  printf("Hit pos = %f", hit_pos.mag());
205 
206  if (hit_pos.mag() > vtx_pos_mag) {
207  if (verbosity >= 2)
208  printf(" X ");
209  needNewTraj = true;
210  } else {
211  newtrajectory.push(Measurements[m]);
212  }
213  if (verbosity >= 2)
214  printf("\n");
215  }
216 
217  return needNewTraj;
218 }
const Point & position() const
position
Definition: Vertex.h:128
DataContainer const & measurements() const
Definition: Trajectory.h:178
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:40
edm::ESHandle< TrackerGeometry > theG
T sqrt(T t)
Definition: SSEVec.h:23
T mag() const
Definition: PV3DBase.h:64
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
const TrackerGeomDet * idToDet(DetId) const override
const reco::Vertex & vertex() const
return the vertex
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
void push(const TrajectoryMeasurement &tm)
Definition: Trajectory.cc:50
#define LogDebug(id)

◆ produce()

void NuclearTrackCorrector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 61 of file NuclearTrackCorrector.cc.

References edm::RefToBase< T >::castTo(), dqmdumpme::first, edm::EventSetup::getHandle(), getNewTrackExtra(), getTrackFromTrajectory(), mps_fire::i, iEvent, Indice_Map, edm::AssociationMap< Tag >::insert(), KeepOnlyCorrectedTracks, reco::NuclearInteraction::likelihood(), LogDebug, m_TrajToTrackCollection, eostools::move(), newTrajNeeded(), reco::NuclearInteraction::primaryTrack(), edm::Handle< T >::product(), edm::AssociationMap< Tag >::refProd(), edm::second(), str_Input_NuclearInteraction, str_Input_Trajectory, swap_map(), theFitter, theFitterToken, theG, theGToken, theMF, theMFToken, thePropagator, thePropagatorToken, HLT_2024v14_cff::track, and verbosity.

61  {
62  // Create Output Collections
63  // --------------------------------------------------------------------------------------------------
64  auto Output_traj = std::make_unique<TrajectoryCollection>();
65  auto Output_trajmap = std::make_unique<TrajectoryToTrajectoryMap>();
66 
67  auto Output_trackextra = std::make_unique<reco::TrackExtraCollection>();
68  auto Output_track = std::make_unique<reco::TrackCollection>();
69  auto Output_trackmap = std::make_unique<TrackToTrajectoryMap>();
70 
71  // Load Reccord
72  // --------------------------------------------------------------------------------------------------
74 
76  theG = iSetup.getHandle(theGToken);
77 
78  reco::TrackExtraRefProd rTrackExtras = iEvent.getRefBeforePut<reco::TrackExtraCollection>();
79 
80  theMF = iSetup.getHandle(theMFToken);
81 
82  // Load Inputs
83  // --------------------------------------------------------------------------------------------------
84  edm::Handle<TrajectoryCollection> temp_m_TrajectoryCollection;
85  iEvent.getByLabel(str_Input_Trajectory, temp_m_TrajectoryCollection);
86  const TrajectoryCollection m_TrajectoryCollection = *(temp_m_TrajectoryCollection.product());
87 
88  edm::Handle<NuclearInteractionCollection> temp_m_NuclearInteractionCollection;
89  iEvent.getByLabel(str_Input_NuclearInteraction, temp_m_NuclearInteractionCollection);
90  const NuclearInteractionCollection m_NuclearInteractionCollection = *(temp_m_NuclearInteractionCollection.product());
91 
92  edm::Handle<TrajTrackAssociationCollection> h_TrajToTrackCollection;
93  iEvent.getByLabel(str_Input_Trajectory, h_TrajToTrackCollection);
94  m_TrajToTrackCollection = h_TrajToTrackCollection.product();
95 
96  // Correct the trajectories (Remove trajectory's hits that are located after the nuclear interacion)
97  // --------------------------------------------------------------------------------------------------
98  if (verbosity >= 1) {
99  LogDebug("NuclearTrackCorrector") << "Number of trajectories = " << m_TrajectoryCollection.size()
100  << std::endl
101  << "Number of nuclear interactions = "
102  << m_NuclearInteractionCollection.size();
103  }
104 
105  std::map<reco::TrackRef, TrajectoryRef> m_TrackToTrajMap;
106  swap_map(temp_m_TrajectoryCollection, m_TrackToTrajMap);
107 
108  for (unsigned int i = 0; i < m_NuclearInteractionCollection.size(); i++) {
109  const reco::NuclearInteraction& ni = m_NuclearInteractionCollection[i];
110  if (ni.likelihood() < 0.4)
111  continue;
112 
113  reco::TrackRef primTrackRef = ni.primaryTrack().castTo<reco::TrackRef>();
114 
115  TrajectoryRef trajRef = m_TrackToTrajMap[primTrackRef];
116 
117  Trajectory newTraj;
118  if (newTrajNeeded(newTraj, trajRef, ni)) {
119  AlgoProductCollection algoResults;
120  bool isOK = getTrackFromTrajectory(newTraj, trajRef, algoResults);
121 
122  if (isOK) {
123  pair<unsigned int, unsigned int> tempory_pair;
124  tempory_pair.first = Output_track->size();
125  tempory_pair.second = i;
126  Indice_Map.push_back(tempory_pair);
127 
128  reco::TrackExtraRef teref = reco::TrackExtraRef(rTrackExtras, i);
129  reco::TrackExtra newTrackExtra = getNewTrackExtra(algoResults);
130  (algoResults[0].track)->setExtra(teref);
131 
132  Output_track->push_back(*algoResults[0].track);
133  Output_trackextra->push_back(newTrackExtra);
134  Output_traj->push_back(newTraj);
135  }
136  } else {
138  Output_track->push_back(*primTrackRef);
139  Output_trackextra->push_back(*primTrackRef->extra());
140  Output_traj->push_back(*trajRef);
141  }
142  }
143  }
144  const edm::OrphanHandle<TrajectoryCollection> Handle_traj = iEvent.put(std::move(Output_traj));
145  const edm::OrphanHandle<reco::TrackCollection> Handle_tracks = iEvent.put(std::move(Output_track));
146  iEvent.put(std::move(Output_trackextra));
147 
148  // Make Maps between elements
149  // --------------------------------------------------------------------------------------------------
150  if (Handle_tracks->size() != Handle_traj->size()) {
151  printf("ERROR Handle_tracks->size() != Handle_traj->size() \n");
152  return;
153  }
154 
155  auto Output_tracktrackmap = std::make_unique<TrackToTrackMap>(Handle_tracks, m_TrajToTrackCollection->refProd().val);
156 
157  for (unsigned int i = 0; i < Indice_Map.size(); i++) {
158  TrajectoryRef InTrajRef(temp_m_TrajectoryCollection, Indice_Map[i].second);
159  TrajectoryRef OutTrajRef(Handle_traj, Indice_Map[i].first);
160  reco::TrackRef TrackRef(Handle_tracks, Indice_Map[i].first);
161 
162  Output_trajmap->insert(OutTrajRef, InTrajRef);
163  Output_trackmap->insert(TrackRef, InTrajRef);
164 
165  try {
166  reco::TrackRef PrimaryTrackRef = m_TrajToTrackCollection->operator[](InTrajRef);
167  Output_tracktrackmap->insert(TrackRef, PrimaryTrackRef);
168  } catch (edm::Exception const&) {
169  }
170  }
171  iEvent.put(std::move(Output_trajmap));
172  iEvent.put(std::move(Output_trackmap));
173  iEvent.put(std::move(Output_tracktrackmap));
174 
175  if (verbosity >= 3)
176  printf("-----------------------\n");
177 }
edm::ESGetToken< Propagator, TrackingComponentsRecord > thePropagatorToken
edm::ESHandle< MagneticField > theMF
std::vector< std::pair< unsigned int, unsigned int > > Indice_Map
T const * product() const
Definition: Handle.h:70
REF castTo() const
Definition: RefToBase.h:243
bool getTrackFromTrajectory(const Trajectory &newTraj, const TrajectoryRef &initialTrajRef, AlgoProductCollection &algoResults)
Get the refitted track from the Trajectory.
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
const ref_type & refProd() const
return ref-prod structure
U second(std::pair< T, U > const &p)
int iEvent
Definition: GenABIO.cc:224
edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > theFitterToken
edm::ESHandle< TrackerGeometry > theG
std::vector< NuclearInteraction > NuclearInteractionCollection
collection of NuclearInteractions
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > theGToken
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
edm::ESHandle< Propagator > thePropagator
const edm::RefToBase< reco::Track > & primaryTrack() const
return the base reference to the primary track
edm::ESHandle< TrajectoryFitter > theFitter
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
void insert(const key_type &k, const data_type &v)
insert an association
reco::TrackExtra getNewTrackExtra(const AlgoProductCollection &algoresults)
get a new TrackExtra from an AlgoProductCollection
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
double likelihood() const
return the likelihood ~ probability that the vertex is a real nuclear interaction ...
edm::Ref< TrajectoryCollection > TrajectoryRef
bool newTrajNeeded(Trajectory &newtrajectory, const TrajectoryRef &trajRef, const reco::NuclearInteraction &ni)
check if the trajectory has to be refitted and get the new trajectory
const TrajTrackAssociationCollection * m_TrajToTrackCollection
std::vector< Trajectory > TrajectoryCollection
void swap_map(const edm::Handle< TrajectoryCollection > &trajColl, std::map< reco::TrackRef, edm::Ref< TrajectoryCollection > > &result)
TrackProducerAlgorithm< reco::Track >::AlgoProductCollection AlgoProductCollection
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theMFToken
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)
std::string str_Input_NuclearInteraction

◆ swap_map()

void NuclearTrackCorrector::swap_map ( const edm::Handle< TrajectoryCollection > &  trajColl,
std::map< reco::TrackRef, edm::Ref< TrajectoryCollection > > &  result 
)
private

Definition at line 330 of file NuclearTrackCorrector.cc.

References mps_fire::i, m_TrajToTrackCollection, and mps_fire::result.

Referenced by produce().

331  {
332  for (unsigned int i = 0; i < trajColl->size(); i++) {
333  TrajectoryRef InTrajRef(trajColl, i);
334  reco::TrackRef PrimaryTrackRef = m_TrajToTrackCollection->operator[](InTrajRef);
335  result[PrimaryTrackRef] = InTrajRef;
336  }
337 }
edm::Ref< TrajectoryCollection > TrajectoryRef
const TrajTrackAssociationCollection * m_TrajToTrackCollection

Member Data Documentation

◆ Indice_Map

std::vector<std::pair<unsigned int, unsigned int> > NuclearTrackCorrector::Indice_Map
private

Definition at line 112 of file NuclearTrackCorrector.h.

Referenced by produce().

◆ int_Input_Hit_Distance

int NuclearTrackCorrector::int_Input_Hit_Distance
private

Definition at line 107 of file NuclearTrackCorrector.h.

◆ KeepOnlyCorrectedTracks

int NuclearTrackCorrector::KeepOnlyCorrectedTracks
private

Definition at line 110 of file NuclearTrackCorrector.h.

Referenced by NuclearTrackCorrector(), and produce().

◆ m_TrajToTrackCollection

const TrajTrackAssociationCollection* NuclearTrackCorrector::m_TrajToTrackCollection
private

Definition at line 125 of file NuclearTrackCorrector.h.

Referenced by getTrackFromTrajectory(), produce(), and swap_map().

◆ str_Input_NuclearInteraction

std::string NuclearTrackCorrector::str_Input_NuclearInteraction
private

Definition at line 106 of file NuclearTrackCorrector.h.

Referenced by NuclearTrackCorrector(), and produce().

◆ str_Input_Trajectory

std::string NuclearTrackCorrector::str_Input_Trajectory
private

Definition at line 105 of file NuclearTrackCorrector.h.

Referenced by NuclearTrackCorrector(), and produce().

◆ theAlgo

TrackProducerAlgorithm<reco::Track>* NuclearTrackCorrector::theAlgo
private

Definition at line 124 of file NuclearTrackCorrector.h.

Referenced by getTrackFromTrajectory(), and NuclearTrackCorrector().

◆ theFitter

edm::ESHandle<TrajectoryFitter> NuclearTrackCorrector::theFitter
private

Definition at line 116 of file NuclearTrackCorrector.h.

Referenced by getTrackFromTrajectory(), and produce().

◆ theFitterToken

edm::ESGetToken<TrajectoryFitter, TrajectoryFitter::Record> NuclearTrackCorrector::theFitterToken
private

Definition at line 120 of file NuclearTrackCorrector.h.

Referenced by NuclearTrackCorrector(), and produce().

◆ theG

edm::ESHandle<TrackerGeometry> NuclearTrackCorrector::theG
private

◆ theGToken

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> NuclearTrackCorrector::theGToken
private

Definition at line 118 of file NuclearTrackCorrector.h.

Referenced by NuclearTrackCorrector(), and produce().

◆ theInitialState

TransientInitialStateEstimator* NuclearTrackCorrector::theInitialState
private

Definition at line 122 of file NuclearTrackCorrector.h.

◆ theMF

edm::ESHandle<MagneticField> NuclearTrackCorrector::theMF
private

Definition at line 115 of file NuclearTrackCorrector.h.

Referenced by getInitialState(), getTrackFromTrajectory(), and produce().

◆ theMFToken

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> NuclearTrackCorrector::theMFToken
private

Definition at line 119 of file NuclearTrackCorrector.h.

Referenced by NuclearTrackCorrector(), and produce().

◆ thePropagator

edm::ESHandle<Propagator> NuclearTrackCorrector::thePropagator
private

Definition at line 117 of file NuclearTrackCorrector.h.

Referenced by getTrackFromTrajectory(), and produce().

◆ thePropagatorToken

edm::ESGetToken<Propagator, TrackingComponentsRecord> NuclearTrackCorrector::thePropagatorToken
private

Definition at line 121 of file NuclearTrackCorrector.h.

Referenced by NuclearTrackCorrector(), and produce().

◆ verbosity

int NuclearTrackCorrector::verbosity
private

Definition at line 109 of file NuclearTrackCorrector.h.

Referenced by newTrajNeeded(), NuclearTrackCorrector(), and produce().