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::stream::EDProducer<> edm::stream::EDProducerBase 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 &) 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< 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::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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, TransientTrackingRecHitBuilder const *hitBuilder)
 

Private Attributes

edm::EDGetTokenT
< reco::TrackCandidateCaloClusterPtrAssociation
assoc_token
 
std::string conversionTrackCandidateProducer_
 
edm::EDGetTokenT
< MeasurementTrackerEvent
measurementTrkToken_
 
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::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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::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 19 of file TrackProducerWithSCAssociation.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file TrackProducerWithSCAssociation.cc.

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

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 209 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.

210 {
211  edm::LogInfo("TrackProducerWithSCAssociation") << "Analyzing event number: " << theEvent.id() << "\n";
212  //
213  // create empty output collections
214  //
215  std::vector<reco::TransientTrack> ttks;
216 
217  //
218  //declare and get stuff to be retrieved from ES
219  //
223  edm::ESHandle<Propagator> thePropagator;
226  getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
227 
228  //
229  //declare and get TrackColection to be retrieved from the event
230  //
231  AlgoProductCollection algoResults;
232  reco::BeamSpot bs;
233 
234  try{
236  getFromEvt(theEvent,theTCCollection,bs);
237 
238  //
239  //run the algorithm
240  //
241  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation run the algorithm" << "\n";
242  theAlgo.runWithCandidate(theG.product(), theMF.product(), *theTCCollection,
243  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
244 
245  } catch (cms::Exception &e){ edm::LogInfo("TrackProducerWithSCAssociation") << "cms::Exception caught!!!" << "\n" << e << "\n";}
246 
247 
248  for (AlgoProductCollection::iterator prod=algoResults.begin();prod!=algoResults.end(); prod++){
249  ttks.push_back( reco::TransientTrack(*(((*prod).second).first),thePropagator.product()->magneticField() ));
250  }
251 
252  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation end" << "\n";
253 
254  return ttks;
255 }
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:86
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.
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, TrackProducerAlgorithm< T >::buildTrack(), generateEDF::cont, PTrajectoryStateOnDet::detId(), alignCSCRings::e, edm::HandleBase::failedToGet(), benchmark_cfg::fc, 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(), ndof, convertSQLiteXML::ok, edm::Handle< T >::product(), edm::ESHandle< class >::product(), edm::Event::put(), putInEvt(), TrackCandidate::recHits(), rTracks_, TrackCandidate::seed(), fileCollector::seed, TrackCandidate::seedRef(), edm::ValueMap< T >::size(), 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  std::auto_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection);
74  std::auto_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection);
75  std::auto_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
76  std::auto_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
77  // Reco Track - Super Cluster Association
78  std::auto_ptr<reco::TrackCaloClusterPtrAssociation> scTrkAssoc_p(new 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 
91 
92 
93  //
94  //declare and get TrackColection to be retrieved from the event
99  theEvent.getByToken(assoc_token, trkCandidateSCAssocHandle);
100  if ( !trkCandidateSCAssocHandle.isValid() ) {
101  // std::cout << "Error! Can't get the product "<<trackCSuperClusterAssociationCollection_.c_str() << " but keep running. Empty collection will be produced " << "\n";
102  edm::LogError("TrackProducerWithSCAssociation") << "Error! Can't get the product "<<trackCSuperClusterAssociationCollection_.c_str() << " but keep running. Empty collection will be produced " << "\n";
104  }
105  reco::TrackCandidateCaloClusterPtrAssociation scTrkCandAssCollection = *(trkCandidateSCAssocHandle.product());
106  if ( scTrkCandAssCollection.size() ==0 ) validTrackCandidateSCAssociationInput_=false;
107 
108 
109  std::vector<int> tccLocations;
110  AlgoProductCollection algoResults;
111  reco::BeamSpot bs;
112 
113 
114  getFromEvt(theEvent,theTCCollection,bs);
115 
116  if (theTCCollection.failedToGet()){
117  edm::LogError("TrackProducerWithSCAssociation") <<"TrackProducerWithSCAssociation could not get the TrackCandidateCollection.";}
118  else{
119  //
120  //run the algorithm
121  //
122  // LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation run the algorithm" << "\n";
123  // theAlgo.runWithCandidate(theG.product(), theMF.product(), *theTCCollection,
124  // theFitter.product(), thePropagator.product(), theBuilder.product(), algoResults);
125  // we have to copy this method from the algo in order to get the association track-seed
126  // this is ugly temporary code that should be replaced!!!!!
127  // start of copied code ======================================================
128 
129  // std::cout << "TrackProducerWithSCAssociation Number of TrackCandidates: " << theTCCollection->size() << "\n";
130  try{
131  int cont = 0;
132  int tcc=0;
133 
134  for (TrackCandidateCollection::const_iterator i=theTCCollection->begin(); i!=theTCCollection->end();i++)
135  {
136 
137  const TrackCandidate * theTC = &(*i);
139  const TrackCandidate::range& recHitVec=theTC->recHits();
140  const TrajectorySeed& seed = theTC->seed();
141 
142  //convert PTrajectoryStateOnDet to TrajectoryStateOnSurface
143 
144 
145  DetId detId(state.detId());
147  &(theG.product()->idToDet(detId)->surface()),
148  theMF.product());
149 
150  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation Initial TSOS\n" << theTSOS << "\n";
151 
152  //convert the TrackingRecHit vector to a TransientTrackingRecHit vector
153  //meanwhile computes the number of degrees of freedom
155 
156  float ndof=0;
157 
159  i!=recHitVec.second; i++){
160  hits.push_back(theBuilder.product()->build(&(*i) ));
161  }
162 
163 
164  //build Track
165  // LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation going to buildTrack"<< "\n";
166  FitterCloner fc(theFitter.product(),theBuilder.product());
167  bool ok = theAlgo.buildTrack(fc.fitter.get(),thePropagator.product(),algoResults, hits, theTSOS, seed, ndof, bs, theTC->seedRef());
168  // LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation buildTrack result: " << ok << "\n";
169  if(ok) {
170  cont++;
171  tccLocations.push_back(tcc);
172  }
173  tcc++;
174  }
175  edm::LogInfo("TrackProducerWithSCAssociation") << "Number of Tracks found: " << cont << "\n";
176  //LogDebug("TrackProducerWithSCAssociation") << "TrackProducerWithSCAssociation Number of Tracks found: " << cont << "\n";
177  // end of copied code ======================================================
178 
179  } catch (cms::Exception &e){ edm::LogInfo("TrackProducerWithSCAssociation") << "cms::Exception caught!!!" << "\n" << e << "\n";}
180  //
181  //put everything in the event
182  // we copy putInEvt to get OrphanHandle filled...
183  putInEvt(theEvent,thePropagator.product(),theMeasTk.product(),
184  outputRHColl, outputTColl, outputTEColl, outputTrajectoryColl, algoResults, theBuilder.product());
185 
186  // now construct associationmap and put it in the event
188  int itrack=0;
189  std::vector<edm::Ptr<reco::CaloCluster> > caloPtrVec;
190  for(AlgoProductCollection::iterator i=algoResults.begin(); i!=algoResults.end();i++){
191  edm::Ref<TrackCandidateCollection> trackCRef(theTCCollection,tccLocations[itrack]);
192  const edm::Ptr<reco::CaloCluster>& aClus = (*trkCandidateSCAssocHandle)[trackCRef];
193  caloPtrVec.push_back( aClus );
194  itrack++;
195  }
196 
197 
198  edm::ValueMap<reco::CaloClusterPtr>::Filler filler(*scTrkAssoc_p);
199  filler.insert(rTracks_, caloPtrVec.begin(), caloPtrVec.end());
200  filler.fill();
201  }
202 
203  theEvent.put(scTrkAssoc_p,trackSuperClusterAssociationCollection_ );
204 
205  }
206 
207 }
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, TransientTrackingRecHitBuilder const *hitBuilder)
int i
Definition: DBlmapReader.cc:9
virtual void getFromEvt(edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
Get TrackCandidateCollection from the Event (needed by TrackProducer)
tuple cont
load Luminosity info ##
Definition: generateEDF.py:622
range recHits() const
edm::OrphanHandle< reco::TrackCollection > rTracks_
TrajectorySeed const & seed() const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
std::vector< ConstRecHitPointer > RecHitContainer
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:75
std::vector< AlgoProduct > AlgoProductCollection
TrackProducerAlgorithm< reco::Track > theAlgo
bool failedToGet() const
Definition: HandleBase.h:79
Definition: DetId.h:18
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
T const * product() const
Definition: Handle.h:81
T const * product() const
Definition: ESHandle.h:86
size_t size() const
Definition: ValueMap.h:157
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
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,
TransientTrackingRecHitBuilder const *  hitBuilder 
)
private

Definition at line 261 of file TrackProducerWithSCAssociation.cc.

References alongMomentum, reco::TrackBase::appendHitPattern(), assert(), TrajectoryStateOnSurface::curvilinearError(), Trajectory::direction(), Trajectory::firstMeasurement(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), TrajectoryStateOnSurface::globalParameters(), i, customizeTrackingMonitorSeedNumber::idx, edm::ESHandleBase::isValid(), Trajectory::lastMeasurement(), measurementTrkToken_, GlobalTrajectoryParameters::momentum(), myTrajectoryInEvent_, AlCaHLTBitMon_ParallelJobs::p, GlobalTrajectoryParameters::position(), edm::Event::put(), TrajectoryMeasurement::recHit(), rTracks_, Trajectory::seedRef(), reco::Track::setExtra(), reco::TrackExtraBase::setHits(), TrackProducerBase< reco::Track >::setSecondHitPattern(), tree::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().

269 {
270 
273 
277  edm::Ref< std::vector<Trajectory> >::key_type iTjRef = 0;
278  std::map<unsigned int, unsigned int> tjTkMap;
279 
280  for(AlgoProductCollection::iterator i=algoResults.begin(); i!=algoResults.end();i++){
281  Trajectory * theTraj = (*i).first;
283  selTrajectories->push_back(*theTraj);
284  iTjRef++;
285  }
286 
287  reco::Track * theTrack = (*i).second.first;
288  PropagationDirection seedDir = (*i).second.second;
289 
290  //LogDebug("TrackProducer") << "In KfTrackProducerBase::putInEvt - seedDir=" << seedDir;
291 
292  reco::Track t = * theTrack;
293  selTracks->push_back( t );
294  iTkRef++;
295 
296  // Store indices in local map (starts at 0)
297  if(trajectoryInEvent_) tjTkMap[iTjRef-1] = iTkRef-1;
298 
299  //sets the outermost and innermost TSOSs
300 
301  TrajectoryStateOnSurface outertsos;
302  TrajectoryStateOnSurface innertsos;
303  unsigned int innerId, outerId;
304 
305  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
306  // This is consistent with innermost and outermost labels only for tracks from LHC collision
307  if (theTraj->direction() == alongMomentum) {
308  outertsos = theTraj->lastMeasurement().updatedState();
309  innertsos = theTraj->firstMeasurement().updatedState();
310  outerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
311  innerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
312  } else {
313  outertsos = theTraj->firstMeasurement().updatedState();
314  innertsos = theTraj->lastMeasurement().updatedState();
315  outerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
316  innerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
317  }
318  // ---
319  //build the TrackExtra
320  GlobalPoint v = outertsos.globalParameters().position();
321  GlobalVector p = outertsos.globalParameters().momentum();
322  math::XYZVector outmom( p.x(), p.y(), p.z() );
323  math::XYZPoint outpos( v.x(), v.y(), v.z() );
324  v = innertsos.globalParameters().position();
325  p = innertsos.globalParameters().momentum();
326  math::XYZVector inmom( p.x(), p.y(), p.z() );
327  math::XYZPoint inpos( v.x(), v.y(), v.z() );
328 
329  reco::TrackExtraRef teref= reco::TrackExtraRef ( rTrackExtras, idx ++ );
330  reco::Track & track = selTracks->back();
331  track.setExtra( teref );
332 
333  //======= I want to set the second hitPattern here =============
334  if (theSchool.isValid())
335  {
338  setSecondHitPattern(theTraj,track,thePropagator,&*mte);
339  }
340  //==============================================================
341 
342 
343  selTrackExtras->push_back( reco::TrackExtra (outpos, outmom, true, inpos, inmom, true,
344  outertsos.curvilinearError(), outerId,
345  innertsos.curvilinearError(), innerId,
346  seedDir,theTraj->seedRef()));
347 
348 
349  reco::TrackExtra & tx = selTrackExtras->back();
350  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
351  // This is consistent with innermost and outermost labels only for tracks from LHC collisions
352  Traj2TrackHits t2t(hitBuilder,false);
353  auto ih = selHits->size();
354  assert(ih==hidx);
355  t2t(*theTraj,*selHits,false);
356  auto const ie = selHits->size();
357  unsigned int nHitsAdded = 0;
358  for (;ih<ie; ++ih) {
359  auto const & hit = (*selHits)[ih];
360  track.appendHitPattern(hit);
361  ++nHitsAdded;
362  }
363  tx.setHits( rHits, hidx, nHitsAdded);
364  hidx +=nHitsAdded;
365  /*
366  if (theTraj->direction() == alongMomentum) {
367  for( TrajectoryFitter::RecHitContainer::const_iterator j = transHits.begin();
368  j != transHits.end(); j ++ ) {
369  if ((**j).hit()!=0){
370  TrackingRecHit * hit = (**j).hit()->clone();
371  track.appendHitPattern(*hit);
372  selHits->push_back( hit );
373  tx.add( TrackingRecHitRef( rHits, hidx ++ ) );
374  }
375  }
376  }else{
377  for( TrajectoryFitter::RecHitContainer::const_iterator j = transHits.end()-1;
378  j != transHits.begin()-1; --j ) {
379  if ((**j).hit()!=0){
380  TrackingRecHit * hit = (**j).hit()->clone();
381  track.appendHitPattern(*hit);
382  selHits->push_back( hit );
383  tx.add( TrackingRecHitRef( rHits, hidx ++ ) );
384  }
385  }
386  }
387  */
388 
389  // ----
390 
391  delete theTrack;
392  delete theTraj;
393  }
394 
395  //LogTrace("TrackingRegressionTest") << "========== TrackProducer Info ===================";
396  //LogDebug("TrackProducerWithSCAssociation") << "number of finalTracks: " << selTracks->size() << std::endl;
397  //for (reco::TrackCollection::const_iterator it = selTracks->begin(); it != selTracks->end(); it++) {
398  //LogDebug("TrackProducerWithSCAssociation") << "track's n valid and invalid hit, chi2, pt : "
399  // << it->found() << " , "
400  // << it->lost() <<" , "
401  // << it->normalizedChi2() << " , "
402  // << it->pt() << std::endl;
403  // }
404  //LogTrace("TrackingRegressionTest") << "=================================================";
405 
406 
407  rTracks_ = evt.put( selTracks );
408 
409 
410  evt.put( selTrackExtras );
411  evt.put( selHits );
412 
414  edm::OrphanHandle<std::vector<Trajectory> > rTrajs = evt.put(selTrajectories);
415 
416  // Now Create traj<->tracks association map
417  std::auto_ptr<TrajTrackAssociationCollection> trajTrackMap( new TrajTrackAssociationCollection(rTrajs, rTracks_) );
418  for ( std::map<unsigned int, unsigned int>::iterator i = tjTkMap.begin();
419  i != tjTkMap.end(); i++ ) {
420  edm::Ref<std::vector<Trajectory> > trajRef( rTrajs, (*i).first );
421  edm::Ref<reco::TrackCollection> tkRef( rTracks_, (*i).second );
422  trajTrackMap->insert( edm::Ref<std::vector<Trajectory> >( rTrajs, (*i).first ),
423  edm::Ref<reco::TrackCollection>( rTracks_, (*i).second ) );
424  }
425  evt.put( trajTrackMap );
426  }
427 }
tuple t
Definition: tree.py:139
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< MeasurementTrackerEvent > measurementTrkToken_
ConstRecHitPointer const & recHit() const
edm::OrphanHandle< reco::TrackCollection > rTracks_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
const CurvilinearTrajectoryError & curvilinearError() const
assert(m_qm.get())
T y() const
Definition: PV3DBase.h:63
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:17
PropagationDirection
PropagationDirection const & direction() const
Definition: Trajectory.cc:118
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:181
void setSecondHitPattern(Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTrackerEvent *measTk)
T z() const
Definition: PV3DBase.h:64
bool appendHitPattern(const TrackingRecHit &hit)
append a single hit to the HitPattern
Definition: TrackBase.h:421
edm::RefToBase< TrajectorySeed > seedRef(void) const
Definition: Trajectory.h:306
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
RefProd< PROD > getRefBeforePut()
Definition: Event.h:135
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
void setExtra(const TrackExtraRef &ref)
set reference to &quot;extra&quot; object
Definition: Track.h:184
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:194
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...
edm::ESHandle< NavigationSchool > theSchool
TrajectoryStateOnSurface const & updatedState() const
bool isValid() const
Definition: ESHandle.h:47
T x() const
Definition: PV3DBase.h:62
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:168

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