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 > edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- 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(), 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_.

20  :
21  TrackProducerBase<reco::Track>(iConfig.getParameter<bool>("TrajectoryInEvent")),
22  theAlgo(iConfig)
23 {
24  setConf(iConfig);
25  setSrc( consumes<TrackCandidateCollection>(iConfig.getParameter<edm::InputTag>( "src" )),
26  consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>( "beamSpot" )),
27  consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>( "MeasurementTrackerEvent") ));
28  setAlias( iConfig.getParameter<std::string>( "@module_label" ) );
29 
30  if ( iConfig.exists("clusterRemovalInfo") ) {
31  edm::InputTag tag = iConfig.getParameter<edm::InputTag>("clusterRemovalInfo");
32  if (!(tag == edm::InputTag())) { setClusterRemovalInfo( tag ); }
33  }
34 
35 
36  myname_ = iConfig.getParameter<std::string>("ComponentName");
38  trackCSuperClusterAssociationCollection_ = iConfig.getParameter<std::string>("trackCandidateSCAssociationCollection");
39  trackSuperClusterAssociationCollection_ = iConfig.getParameter<std::string>("recoTrackSCAssociationCollection");
40  myTrajectoryInEvent_ = iConfig.getParameter<bool>("TrajectoryInEvent");
41 
42  assoc_token =
43  consumes<reco::TrackCandidateCaloClusterPtrAssociation>(
44  edm::InputTag(conversionTrackCandidateProducer_,
45  trackCSuperClusterAssociationCollection_));
47  consumes<MeasurementTrackerEvent>(edm::InputTag("MeasurementTrackerEvent")); //hardcoded because the original was and no time to fix (sigh)
48 
49 
50  //register your products
51  produces<reco::TrackCollection>().setBranchAlias( alias_ + "Tracks" );
52  produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
53  produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
54  produces<std::vector<Trajectory> >() ;
55  produces<TrajTrackAssociationCollection>();
56  // produces< reco::TrackSuperClusterAssociationCollection > (trackSuperClusterAssociationCollection_ );
57  produces< reco::TrackCaloClusterPtrAssociation > (trackSuperClusterAssociationCollection_ );
58 
59 }
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 213 of file TrackProducerWithSCAssociation.cc.

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

214 {
215  edm::LogInfo("TrackProducerWithSCAssociation") << "Analyzing event number: " << theEvent.id() << "\n";
216  //
217  // create empty output collections
218  //
219  std::vector<reco::TransientTrack> ttks;
220 
221  //
222  //declare and get stuff to be retrieved from ES
223  //
227  edm::ESHandle<Propagator> thePropagator;
230  getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
231 
232  //
233  //declare and get TrackColection to be retrieved from the event
234  //
235  AlgoProductCollection algoResults;
236  reco::BeamSpot bs;
237 
238  try{
240  getFromEvt(theEvent,theTCCollection,bs);
241 
242  //
243  //run the algorithm
244  //
245  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation run the algorithm" << "\n";
246  theAlgo.runWithCandidate(theG.product(), theMF.product(), *theTCCollection,
247  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
248 
249  } catch (cms::Exception &e){ edm::LogInfo("TrackProducerWithSCAssociation") << "cms::Exception caught!!!" << "\n" << e << "\n";}
250 
251 
252  for (auto & prod : algoResults){
253  ttks.emplace_back(*prod.track,thePropagator.product()->magneticField());
254  }
255 
256  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation end" << "\n";
257 
258  return ttks;
259 }
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:60
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 62 of file TrackProducerWithSCAssociation.cc.

References assoc_token, TransientTrackingRecHitBuilder::build(), TrackProducerAlgorithm< T >::buildTrack(), PTrajectoryStateOnDet::detId(), MillePedeFileConverter_cfg::e, edm::ValueMap< T >::empty(), edm::HandleBase::failedToGet(), benchmark_cfg::fc, edm::helper::Filler< Map >::fill(), objects.autophobj::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_.

63 {
64  //edm::LogInfo("TrackProducerWithSCAssociation") << "Analyzing event number: " << theEvent.id() << "\n";
65 
66  //LogDebug("TrackProducerWithSCAssociation") << "Analyzing event number: " << theEvent.id() << "\n";
67  // std::cout << " TrackProducerWithSCAssociation Analyzing event number: " << theEvent.id() << "\n";
68 
69 
70  //
71  // create empty output collections
72  //
73  auto outputRHColl = std::make_unique<TrackingRecHitCollection>();
74  auto outputTColl = std::make_unique<reco::TrackCollection>();
75  auto outputTEColl = std::make_unique<reco::TrackExtraCollection>();
76  auto outputTrajectoryColl = std::make_unique<std::vector<Trajectory>>();
77  // Reco Track - Super Cluster Association
78  auto scTrkAssoc_p = std::make_unique<reco::TrackCaloClusterPtrAssociation>();
79 
80  //
81  //declare and get stuff to be retrieved from ES
82  //
86  edm::ESHandle<Propagator> thePropagator;
89  getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
90 
92  setup.get<TrackerTopologyRcd>().get(httopo);
93  const TrackerTopology *ttopo = httopo.product();
94 
95 
96  //
97  //declare and get TrackColection to be retrieved from the event
102  theEvent.getByToken(assoc_token, trkCandidateSCAssocHandle);
103  if ( !trkCandidateSCAssocHandle.isValid() ) {
104  // std::cout << "Error! Can't get the product "<<trackCSuperClusterAssociationCollection_.c_str() << " but keep running. Empty collection will be produced " << "\n";
105  edm::LogError("TrackProducerWithSCAssociation") << "Error! Can't get the product "<<trackCSuperClusterAssociationCollection_.c_str() << " but keep running. Empty collection will be produced " << "\n";
107  }
108  reco::TrackCandidateCaloClusterPtrAssociation scTrkCandAssCollection = *(trkCandidateSCAssocHandle.product());
109  if ( scTrkCandAssCollection.empty() ) validTrackCandidateSCAssociationInput_=false;
110 
111 
112  std::vector<int> tccLocations;
113  AlgoProductCollection algoResults;
114  reco::BeamSpot bs;
115 
116 
117  getFromEvt(theEvent,theTCCollection,bs);
118 
119  if (theTCCollection.failedToGet()){
120  edm::LogError("TrackProducerWithSCAssociation") <<"TrackProducerWithSCAssociation could not get the TrackCandidateCollection.";}
121  else{
122  //
123  //run the algorithm
124  //
125  // LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation run the algorithm" << "\n";
126  // theAlgo.runWithCandidate(theG.product(), theMF.product(), *theTCCollection,
127  // theFitter.product(), thePropagator.product(), theBuilder.product(), algoResults);
128  // we have to copy this method from the algo in order to get the association track-seed
129  // this is ugly temporary code that should be replaced!!!!!
130  // start of copied code ======================================================
131 
132  // std::cout << "TrackProducerWithSCAssociation Number of TrackCandidates: " << theTCCollection->size() << "\n";
133  try{
134  int cont = 0;
135  int tcc=0;
136 
137  for (TrackCandidateCollection::const_iterator i=theTCCollection->begin(); i!=theTCCollection->end();i++)
138  {
139 
140  const TrackCandidate * theTC = &(*i);
142  const TrackCandidate::range& recHitVec=theTC->recHits();
143  const TrajectorySeed& seed = theTC->seed();
144 
145  //convert PTrajectoryStateOnDet to TrajectoryStateOnSurface
146 
147 
148  DetId detId(state.detId());
150  &(theG.product()->idToDet(detId)->surface()),
151  theMF.product());
152 
153  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation Initial TSOS\n" << theTSOS << "\n";
154 
155  //convert the TrackingRecHit vector to a TransientTrackingRecHit vector
156  //meanwhile computes the number of degrees of freedom
158 
159  float ndof=0;
160 
162  i!=recHitVec.second; i++){
163  hits.push_back(theBuilder.product()->build(&(*i) ));
164  }
165 
166 
167  //build Track
168  // LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation going to buildTrack"<< "\n";
169  FitterCloner fc(theFitter.product(),theBuilder.product());
170  bool ok = theAlgo.buildTrack(fc.fitter.get(),thePropagator.product(),algoResults, hits, theTSOS, seed, ndof, bs, theTC->seedRef());
171  // LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation buildTrack result: " << ok << "\n";
172  if(ok) {
173  cont++;
174  tccLocations.push_back(tcc);
175  }
176  tcc++;
177  }
178  edm::LogInfo("TrackProducerWithSCAssociation") << "Number of Tracks found: " << cont << "\n";
179  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation Number of Tracks found: " << cont << "\n";
180  // end of copied code ======================================================
181 
182  } catch (cms::Exception &e){ edm::LogInfo("TrackProducerWithSCAssociation") << "cms::Exception caught!!!" << "\n" << e << "\n";}
183  //
184  //put everything in the event
185  // we copy putInEvt to get OrphanHandle filled...
186  putInEvt(theEvent,thePropagator.product(),theMeasTk.product(),
187  std::move(outputRHColl), std::move(outputTColl), std::move(outputTEColl), std::move(outputTrajectoryColl),
188  algoResults, theBuilder.product(), 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 
201 
203  filler.insert(rTracks_, caloPtrVec.begin(), caloPtrVec.end());
204  filler.fill();
205  }
206 
207  theEvent.put(std::move(scTrkAssoc_p),trackSuperClusterAssociationCollection_ );
208 
209  }
210 
211 }
bool empty() const
Definition: ValueMap.h:160
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
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
edm::EDGetTokenT< reco::TrackCandidateCaloClusterPtrAssociation > assoc_token
std::pair< const_iterator, const_iterator > range
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:74
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:78
Definition: DetId.h:18
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
T const * product() const
Definition: Handle.h:81
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:510
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 265 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(), lumiQTWidget::t, TrackProducerBase< reco::Track >::theSchool, HiIsolationCommonParameters_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().

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

Member Data Documentation

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

Definition at line 35 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and TrackProducerWithSCAssociation().

std::string TrackProducerWithSCAssociation::conversionTrackCandidateProducer_
private

Definition at line 32 of file TrackProducerWithSCAssociation.h.

Referenced by TrackProducerWithSCAssociation().

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

Definition at line 37 of file TrackProducerWithSCAssociation.h.

Referenced by putInEvt(), and TrackProducerWithSCAssociation().

std::string TrackProducerWithSCAssociation::myname_
private

Definition at line 30 of file TrackProducerWithSCAssociation.h.

Referenced by TrackProducerWithSCAssociation().

bool TrackProducerWithSCAssociation::myTrajectoryInEvent_
private

Definition at line 38 of file TrackProducerWithSCAssociation.h.

Referenced by putInEvt(), and TrackProducerWithSCAssociation().

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

Definition at line 36 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and putInEvt().

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

Definition at line 31 of file TrackProducerWithSCAssociation.h.

Referenced by getTransient(), and produce().

std::string TrackProducerWithSCAssociation::trackCSuperClusterAssociationCollection_
private

Definition at line 33 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and TrackProducerWithSCAssociation().

std::string TrackProducerWithSCAssociation::trackSuperClusterAssociationCollection_
private

Definition at line 34 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and TrackProducerWithSCAssociation().

bool TrackProducerWithSCAssociation::validTrackCandidateSCAssociationInput_
private

Definition at line 39 of file TrackProducerWithSCAssociation.h.

Referenced by produce().