test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecoTrackAccumulator.cc
Go to the documentation of this file.
1 #include "RecoTrackAccumulator.h"
4 
6  InputSignal_(conf.getParameter<edm::InputTag>("InputSignal")),
7  InputPileup_(conf.getParameter<edm::InputTag>("InputPileup")),
8  GeneralTrackOutput_(conf.getParameter<std::string>("GeneralTrackOutput")),
9  HitOutput_(conf.getParameter<std::string>("HitOutput")),
10  GeneralTrackExtraOutput_(conf.getParameter<std::string>("GeneralTrackExtraOutput"))
11 {
12 
14  mixMod.produces<TrackingRecHitCollection>(HitOutput_);
16 
20 }
21 
23 
24 }
25 
27 
28  NewTrackList_ = std::auto_ptr<reco::TrackCollection>(new reco::TrackCollection());
29  NewHitList_ = std::auto_ptr<TrackingRecHitCollection>(new TrackingRecHitCollection());
30  NewTrackExtraList_ = std::auto_ptr<reco::TrackExtraCollection>(new reco::TrackExtraCollection());
31 
32  // this is needed to get the ProductId of the TrackExtra and TrackingRecHit collections
33  rTrackExtras=const_cast<edm::Event&>( e ).getRefBeforePut<reco::TrackExtraCollection>(GeneralTrackExtraOutput_);
34  rHits=const_cast<edm::Event&>( e ).getRefBeforePut<TrackingRecHitCollection>(HitOutput_);
35 
36 }
37 
39 
40 
44  e.getByLabel(InputSignal_, tracks);
45  e.getByLabel(InputSignal_, hits);
46  e.getByLabel(InputSignal_, trackExtras);
47 
48  // Call the templated version that does the same for both signal and pileup events
49  accumulateEvent( e, iSetup, tracks, trackExtras, hits );
50 
51 }
52 
54 
55  if (e.bunchCrossing()==0) {
59  e.getByLabel(InputPileup_, tracks);
60  e.getByLabel(InputPileup_, hits);
61  e.getByLabel(InputPileup_, trackExtras);
62 
63  // Call the templated version that does the same for both signal and pileup events
64  accumulateEvent( e, iSetup, tracks, trackExtras, hits );
65 
66  }
67 }
68 
70 
74 
75 }
76 
77 
79 
80  if (tracks.isValid()) {
81  for (auto const& track : *tracks) {
82  NewTrackList_->push_back(track);
83  // track extras:
84  auto const& extra = tracksExtras->at(track.extra().key());
85  NewTrackExtraList_->emplace_back(extra.outerPosition(), extra.outerMomentum(), extra.outerOk(),
86  extra.innerPosition(),extra.innerMomentum(), extra.innerOk(),
87  extra.outerStateCovariance(), extra.outerDetId(),
88  extra.innerStateCovariance(), extra.innerDetId(),
89  extra.seedDirection(),
90  //If TrajectorySeeds are needed, then their list must be gotten from the
91  // secondary event directly and looked up similarly to TrackExtras.
92  //We can't use a default constructed RefToBase due to a bug in RefToBase
93  // which causes an seg fault when calling isAvailable on a default constructed one.
95  NewTrackList_->back().setExtra( reco::TrackExtraRef( rTrackExtras, NewTrackExtraList_->size() - 1) );
96  //reco::TrackExtra & tx = NewTrackExtraList_->back();
97  //tx.setResiduals(track.residuals());
98  // rechits:
99  auto & newExtra = NewTrackExtraList_->back();
100  for( trackingRecHit_iterator hit = extra.recHitsBegin(); hit != extra.recHitsEnd(); ++ hit ) {
101  NewHitList_->push_back( (*hits)[hit->key()] );
102  newExtra.add( TrackingRecHitRef( rHits, NewHitList_->size() - 1) );
103  }
104  }
105  }
106 
107 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
std::auto_ptr< TrackingRecHitCollection > NewHitList_
std::auto_ptr< reco::TrackCollection > NewTrackList_
RecoTrackAccumulator(const edm::ParameterSet &conf, edm::one::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
TrackingRecHitRefProd rHits
virtual void accumulate(edm::Event const &e, edm::EventSetup const &c)
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
bool isValid() const
Definition: HandleBase.h:76
std::auto_ptr< reco::TrackExtraCollection > NewTrackExtraList_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
tuple conf
Definition: dbtoconf.py:185
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:9
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
tuple tracks
Definition: testEve_cfg.py:39
reco::TrackExtraRefProd rTrackExtras
virtual void finalizeEvent(edm::Event &e, edm::EventSetup const &c)
virtual void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
std::string GeneralTrackExtraOutput_
void accumulateEvent(const T &e, edm::EventSetup const &c, edm::Handle< reco::TrackCollection > t, edm::Handle< reco::TrackExtraCollection > tx, edm::Handle< TrackingRecHitCollection > h)
long double T