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"
5 
7  Input_(conf.getParameter<edm::InputTag>("Input")),
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  accumulateEvent( e, iSetup);
40 }
41 
43  if (e.bunchCrossing()==0) {
44  accumulateEvent( e, iSetup);
45  }
46 }
47 
49 
53 
54 }
55 
56 
57 template<class T> void RecoTrackAccumulator::accumulateEvent(const T& e, edm::EventSetup const& iSetup) {
58 
62  if(!(e.getByLabel(Input_, tracks) and e.getByLabel(Input_, hits) and e.getByLabel(Input_, trackExtras))){
63  edm::LogError ("Failed to find track, hit or trackExtra collections");
64  exit(1);
65  }
66  // check validaity here
67 
68  for (auto const& track : *tracks) {
69  NewTrackList_->push_back(track);
70  // track extras:
71  auto const& extra = trackExtras->at(track.extra().key());
72  NewTrackExtraList_->emplace_back(extra.outerPosition(), extra.outerMomentum(), extra.outerOk(),
73  extra.innerPosition(),extra.innerMomentum(), extra.innerOk(),
74  extra.outerStateCovariance(), extra.outerDetId(),
75  extra.innerStateCovariance(), extra.innerDetId(),
76  extra.seedDirection(),
77  //If TrajectorySeeds are needed, then their list must be gotten from the
78  // secondary event directly and looked up similarly to TrackExtras.
79  //We can't use a default constructed RefToBase due to a bug in RefToBase
80  // which causes an seg fault when calling isAvailable on a default constructed one.
82  NewTrackList_->back().setExtra( reco::TrackExtraRef( rTrackExtras, NewTrackExtraList_->size() - 1) );
83  // rechits:
84  // note: extra.recHit(i) does not work for pileup events
85  // probably the Ref does not know its product id applies on a pileup event
86  auto & newExtra = NewTrackExtraList_->back();
87  auto const firstTrackIndex = NewHitList_->size();
88  for(unsigned int i = 0;i<extra.recHitsSize();i++){
89  NewHitList_->push_back( (*hits)[extra.recHit(i).key()] );
90  }
91  newExtra.setHits( rHits, firstTrackIndex, NewHitList_->size() - firstTrackIndex);
92  }
93 
94 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int i
Definition: DBlmapReader.cc:9
void accumulateEvent(const T &e, edm::EventSetup const &c)
#define Input_(cl, h, l)
Definition: vmac.h:189
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
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:113
std::auto_ptr< reco::TrackExtraCollection > NewTrackExtraList_
tuple conf
Definition: dbtoconf.py:185
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
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)
std::string GeneralTrackExtraOutput_
long double T