CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

std::vector< reco::TransientTrackgetTransient (edm::Event &, const edm::EventSetup &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 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< TrackCollection > &, 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)
 
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 ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

edm::EDGetTokenT
< reco::TrackCandidateCaloClusterPtrAssociation
assoc_token
 
std::string conversionTrackCandidateProducer_
 
std::string myname_
 
bool myTrajectoryInEvent_
 
edm::OrphanHandle
< reco::TrackCollection
rTracks_
 
TrackProducerAlgorithm
< reco::Track
theAlgo
 
std::string trackCSuperClusterAssociationCollection_
 
std::string trackSuperClusterAssociationCollection_
 
bool validTrackCandidateSCAssociationInput_
 

Additional Inherited Members

- Public Types inherited from TrackProducerBase< reco::Track >
typedef std::pair< Trajectory
*, std::pair< reco::Track
*, PropagationDirection > > 
AlgoProduct
 
typedef std::vector< AlgoProductAlgoProductCollection
 
typedef std::vector< reco::TrackTrackCollection
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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::EDGetTokenT
< MeasurementTrackerEvent
mteSrc_
 
bool rekeyClusterRefs_
 
edm::OrphanHandle
< TrackCollection
rTracks_
 
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 18 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(), 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_));
46 
47  //register your products
48  produces<reco::TrackCollection>().setBranchAlias( alias_ + "Tracks" );
49  produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
50  produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
51  produces<std::vector<Trajectory> >() ;
52  produces<TrajTrackAssociationCollection>();
53  // produces< reco::TrackSuperClusterAssociationCollection > (trackSuperClusterAssociationCollection_ );
54  produces< reco::TrackCaloClusterPtrAssociation > (trackSuperClusterAssociationCollection_ );
55 
56 }
T getParameter(std::string const &) const
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 205 of file TrackProducerWithSCAssociation.cc.

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

206 {
207  edm::LogInfo("TrackProducerWithSCAssociation") << "Analyzing event number: " << theEvent.id() << "\n";
208  //
209  // create empty output collections
210  //
211  std::vector<reco::TransientTrack> ttks;
212 
213  //
214  //declare and get stuff to be retrieved from ES
215  //
219  edm::ESHandle<Propagator> thePropagator;
222  getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
223 
224  //
225  //declare and get TrackColection to be retrieved from the event
226  //
227  AlgoProductCollection algoResults;
228  reco::BeamSpot bs;
229 
230  try{
232  getFromEvt(theEvent,theTCCollection,bs);
233 
234  //
235  //run the algorithm
236  //
237  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation run the algorithm" << "\n";
238  theAlgo.runWithCandidate(theG.product(), theMF.product(), *theTCCollection,
239  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
240 
241  } catch (cms::Exception &e){ edm::LogInfo("TrackProducerWithSCAssociation") << "cms::Exception caught!!!" << "\n" << e << "\n";}
242 
243 
244  for (AlgoProductCollection::iterator prod=algoResults.begin();prod!=algoResults.end(); prod++){
245  ttks.push_back( reco::TransientTrack(*(((*prod).second).first),thePropagator.product()->magneticField() ));
246  }
247 
248  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation end" << "\n";
249 
250  return ttks;
251 }
virtual void getFromEvt(edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
Get TrackCandidateCollection from the Event (needed by TrackProducer)
std::vector< AlgoProduct > AlgoProductCollection
TrackProducerAlgorithm< reco::Track > theAlgo
T const * product() const
Definition: ESHandle.h:62
edm::EventID id() const
Definition: EventBase.h:56
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.
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 theEvent,
const edm::EventSetup setup 
)
virtual

Implements edm::EDProducer.

Definition at line 59 of file TrackProducerWithSCAssociation.cc.

References assoc_token, TrackProducerAlgorithm< T >::buildTrack(), cont, PTrajectoryStateOnDet::detId(), alignCSCRings::e, edm::HandleBase::failedToGet(), edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), TrackProducerBase< reco::Track >::getFromES(), TrackProducerBase< reco::Track >::getFromEvt(), i, edm::helper::Filler< Map >::insert(), edm::HandleBase::isValid(), convertSQLiteXML::ok, edm::Handle< T >::product(), edm::ESHandle< class >::product(), edm::Event::put(), putInEvt(), TrackCandidate::recHits(), rTracks_, TrackCandidate::seed(), TrackCandidate::seedRef(), edm::ValueMap< T >::size(), theAlgo, trackCSuperClusterAssociationCollection_, trackSuperClusterAssociationCollection_, TrackCandidate::trajectoryStateOnDet(), trajectoryStateTransform::transientState(), and validTrackCandidateSCAssociationInput_.

60 {
61  //edm::LogInfo("TrackProducerWithSCAssociation") << "Analyzing event number: " << theEvent.id() << "\n";
62 
63  //LogDebug("TrackProducerWithSCAssociation") << "Analyzing event number: " << theEvent.id() << "\n";
64  // std::cout << " TrackProducerWithSCAssociation Analyzing event number: " << theEvent.id() << "\n";
65 
66 
67  //
68  // create empty output collections
69  //
70  std::auto_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection);
71  std::auto_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection);
72  std::auto_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
73  std::auto_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
74  // Reco Track - Super Cluster Association
75  std::auto_ptr<reco::TrackCaloClusterPtrAssociation> scTrkAssoc_p(new reco::TrackCaloClusterPtrAssociation);
76 
77  //
78  //declare and get stuff to be retrieved from ES
79  //
83  edm::ESHandle<Propagator> thePropagator;
86  getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
87 
88 
89 
90  //
91  //declare and get TrackColection to be retrieved from the event
96  theEvent.getByToken(assoc_token, trkCandidateSCAssocHandle);
97  if ( !trkCandidateSCAssocHandle.isValid() ) {
98  // std::cout << "Error! Can't get the product "<<trackCSuperClusterAssociationCollection_.c_str() << " but keep running. Empty collection will be produced " << "\n";
99  edm::LogError("TrackProducerWithSCAssociation") << "Error! Can't get the product "<<trackCSuperClusterAssociationCollection_.c_str() << " but keep running. Empty collection will be produced " << "\n";
101  }
102  reco::TrackCandidateCaloClusterPtrAssociation scTrkCandAssCollection = *(trkCandidateSCAssocHandle.product());
103  if ( scTrkCandAssCollection.size() ==0 ) validTrackCandidateSCAssociationInput_=false;
104 
105 
106  std::vector<int> tccLocations;
107  AlgoProductCollection algoResults;
108  reco::BeamSpot bs;
109 
110 
111  getFromEvt(theEvent,theTCCollection,bs);
112 
113  if (theTCCollection.failedToGet()){
114  edm::LogError("TrackProducerWithSCAssociation") <<"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  {
133 
134  const TrackCandidate * theTC = &(*i);
136  const TrackCandidate::range& recHitVec=theTC->recHits();
137  const TrajectorySeed& seed = theTC->seed();
138 
139  //convert PTrajectoryStateOnDet to TrajectoryStateOnSurface
140 
141 
142  DetId detId(state.detId());
144  &(theG.product()->idToDet(detId)->surface()),
145  theMF.product());
146 
147  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation Initial TSOS\n" << theTSOS << "\n";
148 
149  //convert the TrackingRecHit vector to a TransientTrackingRecHit vector
150  //meanwhile computes the number of degrees of freedom
152 
153  float ndof=0;
154 
156  i!=recHitVec.second; i++){
157  hits.push_back(theBuilder.product()->build(&(*i) ));
158  }
159 
160 
161  //build Track
162  // LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation going to buildTrack"<< "\n";
163  bool ok = theAlgo.buildTrack(theFitter.product(),thePropagator.product(),algoResults, hits, theTSOS, seed, ndof, bs, theTC->seedRef());
164  // LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation buildTrack result: " << ok << "\n";
165  if(ok) {
166  cont++;
167  tccLocations.push_back(tcc);
168  }
169  tcc++;
170  }
171  edm::LogInfo("TrackProducerWithSCAssociation") << "Number of Tracks found: " << cont << "\n";
172  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation Number of Tracks found: " << cont << "\n";
173  // end of copied code ======================================================
174 
175  } catch (cms::Exception &e){ edm::LogInfo("TrackProducerWithSCAssociation") << "cms::Exception caught!!!" << "\n" << e << "\n";}
176  //
177  //put everything in the event
178  // we copy putInEvt to get OrphanHandle filled...
179  putInEvt(theEvent,thePropagator.product(),theMeasTk.product(),
180  outputRHColl, outputTColl, outputTEColl, outputTrajectoryColl, algoResults);
181 
182  // now construct associationmap and put it in the event
184  int itrack=0;
185  std::vector<edm::Ptr<reco::CaloCluster> > caloPtrVec;
186  for(AlgoProductCollection::iterator i=algoResults.begin(); i!=algoResults.end();i++){
187  edm::Ref<TrackCandidateCollection> trackCRef(theTCCollection,tccLocations[itrack]);
188  const edm::Ptr<reco::CaloCluster>& aClus = (*trkCandidateSCAssocHandle)[trackCRef];
189  caloPtrVec.push_back( aClus );
190  itrack++;
191  }
192 
193 
194  edm::ValueMap<reco::CaloClusterPtr>::Filler filler(*scTrkAssoc_p);
195  filler.insert(rTracks_, caloPtrVec.begin(), caloPtrVec.end());
196  filler.fill();
197  }
198 
199  theEvent.put(scTrkAssoc_p,trackSuperClusterAssociationCollection_ );
200 
201  }
202 
203 }
int i
Definition: DBlmapReader.cc:9
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_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
TrajectorySeed const & seed() const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
edm::EDGetTokenT< reco::TrackCandidateCaloClusterPtrAssociation > assoc_token
std::pair< const_iterator, const_iterator > range
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.
void putInEvt(edm::Event &evt, const Propagator *thePropagator, const MeasurementTracker *theMeasTk, std::auto_ptr< TrackingRecHitCollection > &selHits, std::auto_ptr< reco::TrackCollection > &selTracks, std::auto_ptr< reco::TrackExtraCollection > &selTrackExtras, std::auto_ptr< std::vector< Trajectory > > &selTrajectories, AlgoProductCollection &algoResults)
PTrajectoryStateOnDet const & trajectoryStateOnDet() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
unsigned int detId() const
bool isValid() const
Definition: HandleBase.h:76
std::vector< AlgoProduct > AlgoProductCollection
TrackProducerAlgorithm< reco::Track > theAlgo
bool failedToGet() const
Definition: HandleBase.h:80
Definition: DetId.h:18
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:9
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:81
int cont
size_t size() const
Definition: ValueMap.h:151
edm::RefToBase< TrajectorySeed > seedRef() 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.
void TrackProducerWithSCAssociation::putInEvt ( edm::Event evt,
const Propagator thePropagator,
const MeasurementTracker theMeasTk,
std::auto_ptr< TrackingRecHitCollection > &  selHits,
std::auto_ptr< reco::TrackCollection > &  selTracks,
std::auto_ptr< reco::TrackExtraCollection > &  selTrackExtras,
std::auto_ptr< std::vector< Trajectory > > &  selTrajectories,
AlgoProductCollection algoResults 
)
private

Definition at line 256 of file TrackProducerWithSCAssociation.cc.

References reco::TrackExtraBase::add(), alongMomentum, TrajectoryStateOnSurface::curvilinearError(), Trajectory::direction(), Trajectory::firstMeasurement(), edm::Event::getByLabel(), edm::Event::getRefBeforePut(), TrajectoryStateOnSurface::globalParameters(), i, customizeTrackingMonitorSeedNumber::idx, edm::ESHandleBase::isValid(), j, gen::k, Trajectory::lastMeasurement(), GlobalTrajectoryParameters::momentum(), myTrajectoryInEvent_, AlCaHLTBitMon_ParallelJobs::p, GlobalTrajectoryParameters::position(), edm::Event::put(), TrajectoryMeasurement::recHit(), Trajectory::recHits(), rTracks_, Trajectory::seedRef(), reco::Track::setExtra(), reco::TrackBase::setHitPattern(), TrackProducerBase< reco::Track >::setSecondHitPattern(), lumiQTWidget::t, TrackProducerBase< reco::Track >::theSchool, 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().

264 {
265 
268 
272  edm::Ref< std::vector<Trajectory> >::key_type iTjRef = 0;
273  std::map<unsigned int, unsigned int> tjTkMap;
274 
275  for(AlgoProductCollection::iterator i=algoResults.begin(); i!=algoResults.end();i++){
276  Trajectory * theTraj = (*i).first;
278  selTrajectories->push_back(*theTraj);
279  iTjRef++;
280  }
281  const TrajectoryFitter::RecHitContainer& transHits = theTraj->recHits();
282 
283  reco::Track * theTrack = (*i).second.first;
284  PropagationDirection seedDir = (*i).second.second;
285 
286  //LogDebug("TrackProducer") << "In KfTrackProducerBase::putInEvt - seedDir=" << seedDir;
287 
288  reco::Track t = * theTrack;
289  selTracks->push_back( t );
290  iTkRef++;
291 
292  // Store indices in local map (starts at 0)
293  if(trajectoryInEvent_) tjTkMap[iTjRef-1] = iTkRef-1;
294 
295  //sets the outermost and innermost TSOSs
296 
297  TrajectoryStateOnSurface outertsos;
298  TrajectoryStateOnSurface innertsos;
299  unsigned int innerId, outerId;
300 
301  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
302  // This is consistent with innermost and outermost labels only for tracks from LHC collision
303  if (theTraj->direction() == alongMomentum) {
304  outertsos = theTraj->lastMeasurement().updatedState();
305  innertsos = theTraj->firstMeasurement().updatedState();
306  outerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
307  innerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
308  } else {
309  outertsos = theTraj->firstMeasurement().updatedState();
310  innertsos = theTraj->lastMeasurement().updatedState();
311  outerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
312  innerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
313  }
314  // ---
315  //build the TrackExtra
316  GlobalPoint v = outertsos.globalParameters().position();
317  GlobalVector p = outertsos.globalParameters().momentum();
318  math::XYZVector outmom( p.x(), p.y(), p.z() );
319  math::XYZPoint outpos( v.x(), v.y(), v.z() );
320  v = innertsos.globalParameters().position();
321  p = innertsos.globalParameters().momentum();
322  math::XYZVector inmom( p.x(), p.y(), p.z() );
323  math::XYZPoint inpos( v.x(), v.y(), v.z() );
324 
325  reco::TrackExtraRef teref= reco::TrackExtraRef ( rTrackExtras, idx ++ );
326  reco::Track & track = selTracks->back();
327  track.setExtra( teref );
328 
329  //======= I want to set the second hitPattern here =============
330  if (theSchool.isValid())
331  {
333  evt.getByLabel(edm::InputTag("MeasurementTrackerEvent"), mte);
334  NavigationSetter setter( *theSchool );
335  setSecondHitPattern(theTraj,track,thePropagator,&*mte);
336  }
337  //==============================================================
338 
339 
340  selTrackExtras->push_back( reco::TrackExtra (outpos, outmom, true, inpos, inmom, true,
341  outertsos.curvilinearError(), outerId,
342  innertsos.curvilinearError(), innerId,
343  seedDir,theTraj->seedRef()));
344 
345 
346  reco::TrackExtra & tx = selTrackExtras->back();
347  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
348  // This is consistent with innermost and outermost labels only for tracks from LHC collisions
349  size_t k = 0;
350  if (theTraj->direction() == alongMomentum) {
351  for( TrajectoryFitter::RecHitContainer::const_iterator j = transHits.begin();
352  j != transHits.end(); j ++ ) {
353  if ((**j).hit()!=0){
354  TrackingRecHit * hit = (**j).hit()->clone();
355  track.setHitPattern( * hit, k++ );
356  selHits->push_back( hit );
357  tx.add( TrackingRecHitRef( rHits, hidx ++ ) );
358  }
359  }
360  }else{
361  for( TrajectoryFitter::RecHitContainer::const_iterator j = transHits.end()-1;
362  j != transHits.begin()-1; --j ) {
363  if ((**j).hit()!=0){
364  TrackingRecHit * hit = (**j).hit()->clone();
365  track.setHitPattern( * hit, k++ );
366  selHits->push_back( hit );
367  tx.add( TrackingRecHitRef( rHits, hidx ++ ) );
368  }
369  }
370  }
371  // ----
372 
373  delete theTrack;
374  delete theTraj;
375  }
376 
377  //LogTrace("TrackingRegressionTest") << "========== TrackProducer Info ===================";
378  //LogDebug("TrackProducerWithSCAssociation") << "number of finalTracks: " << selTracks->size() << std::endl;
379  //for (reco::TrackCollection::const_iterator it = selTracks->begin(); it != selTracks->end(); it++) {
380  //LogDebug("TrackProducerWithSCAssociation") << "track's n valid and invalid hit, chi2, pt : "
381  // << it->found() << " , "
382  // << it->lost() <<" , "
383  // << it->normalizedChi2() << " , "
384  // << it->pt() << std::endl;
385  // }
386  //LogTrace("TrackingRegressionTest") << "=================================================";
387 
388 
389  rTracks_ = evt.put( selTracks );
390 
391 
392  evt.put( selTrackExtras );
393  evt.put( selHits );
394 
396  edm::OrphanHandle<std::vector<Trajectory> > rTrajs = evt.put(selTrajectories);
397 
398  // Now Create traj<->tracks association map
399  std::auto_ptr<TrajTrackAssociationCollection> trajTrackMap( new TrajTrackAssociationCollection() );
400  for ( std::map<unsigned int, unsigned int>::iterator i = tjTkMap.begin();
401  i != tjTkMap.end(); i++ ) {
402  edm::Ref<std::vector<Trajectory> > trajRef( rTrajs, (*i).first );
403  edm::Ref<reco::TrackCollection> tkRef( rTracks_, (*i).second );
404  trajTrackMap->insert( edm::Ref<std::vector<Trajectory> >( rTrajs, (*i).first ),
405  edm::Ref<reco::TrackCollection>( rTracks_, (*i).second ) );
406  }
407  evt.put( trajTrackMap );
408  }
409 
410 
411 
412 
413 
414 
415 }
int i
Definition: DBlmapReader.cc:9
ConstRecHitPointer const & recHit() const
edm::OrphanHandle< reco::TrackCollection > rTracks_
const CurvilinearTrajectoryError & curvilinearError() const
T y() const
Definition: PV3DBase.h:63
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:13
PropagationDirection
ConstRecHitContainer recHits(bool splitting=false) const
Definition: Trajectory.cc:67
PropagationDirection const & direction() const
Definition: Trajectory.cc:196
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
edm::Ref< TrackingRecHitCollection > TrackingRecHitRef
persistent reference to a TrackingRecHit
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:193
void setSecondHitPattern(Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTrackerEvent *measTk)
T z() const
Definition: PV3DBase.h:64
int j
Definition: DBlmapReader.cc:9
edm::RefToBase< TrajectorySeed > seedRef(void) const
Definition: Trajectory.h:308
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
RefProd< PROD > getRefBeforePut()
Definition: Event.h:128
int k[5][pyjets_maxn]
virtual TrackingRecHit * clone() const =0
void setHitPattern(const C &c)
set hit patterns from vector of hit references
Definition: TrackBase.h:244
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:9
void setExtra(const TrackExtraRef &ref)
set reference to &quot;extra&quot; object
Definition: Track.h:94
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:206
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
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
void add(const TrackingRecHitRef &r)
add a reference to a RecHit
edm::ESHandle< NavigationSchool > theSchool
TrajectoryStateOnSurface const & updatedState() const
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:170
bool isValid() const
Definition: ESHandle.h:37
T x() const
Definition: PV3DBase.h:62
Trajectory::RecHitContainer RecHitContainer

Member Data Documentation

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

Definition at line 34 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and TrackProducerWithSCAssociation().

std::string TrackProducerWithSCAssociation::conversionTrackCandidateProducer_
private

Definition at line 31 of file TrackProducerWithSCAssociation.h.

Referenced by TrackProducerWithSCAssociation().

std::string TrackProducerWithSCAssociation::myname_
private

Definition at line 29 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 35 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and putInEvt().

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

Definition at line 30 of file TrackProducerWithSCAssociation.h.

Referenced by getTransient(), and produce().

std::string TrackProducerWithSCAssociation::trackCSuperClusterAssociationCollection_
private

Definition at line 32 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and TrackProducerWithSCAssociation().

std::string TrackProducerWithSCAssociation::trackSuperClusterAssociationCollection_
private

Definition at line 33 of file TrackProducerWithSCAssociation.h.

Referenced by produce(), and TrackProducerWithSCAssociation().

bool TrackProducerWithSCAssociation::validTrackCandidateSCAssociationInput_
private

Definition at line 37 of file TrackProducerWithSCAssociation.h.

Referenced by produce().