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.
7 
8 
10  signalTracksTag(conf.getParameter<edm::InputTag>("signalTracks")),
11  pileUpTracksTag(conf.getParameter<edm::InputTag>("pileUpTracks")),
12  outputLabel(conf.getParameter<std::string>("outputLabel"))
13 {
14  mixMod.produces<reco::TrackCollection>(outputLabel);
15  mixMod.produces<TrackingRecHitCollection>(outputLabel);
16  mixMod.produces<reco::TrackExtraCollection>(outputLabel);
17 
21 }
22 
24 
25 }
26 
28 
29  newTracks_ = std::auto_ptr<reco::TrackCollection>(new reco::TrackCollection);
30  newHits_ = std::auto_ptr<TrackingRecHitCollection>(new TrackingRecHitCollection);
31  newTrackExtras_ = std::auto_ptr<reco::TrackExtraCollection>(new reco::TrackExtraCollection);
32 
33  // this is needed to get the ProductId of the TrackExtra and TrackingRecHit and Track collections
34  rNewTracks=const_cast<edm::Event&>( e ).getRefBeforePut<reco::TrackCollection>(outputLabel);
35  rNewTrackExtras=const_cast<edm::Event&>( e ).getRefBeforePut<reco::TrackExtraCollection>(outputLabel);
36  rNewHits=const_cast<edm::Event&>( e ).getRefBeforePut<TrackingRecHitCollection>(outputLabel);
37 }
38 
40  accumulateEvent( e, iSetup,signalTracksTag);
41 }
42 
44  if (e.bunchCrossing()==0) {
45  accumulateEvent( e, iSetup,pileUpTracksTag);
46  }
47 }
48 
50 
52  e.put( newHits_, outputLabel );
54 }
55 
56 
57 template<class T> void RecoTrackAccumulator::accumulateEvent(const T& e, edm::EventSetup const& iSetup,const edm::InputTag & label) {
58 
62  e.getByLabel(label, tracks);
63  e.getByLabel(label, hits);
64  e.getByLabel(label, trackExtras);
65 
66  if(! tracks.isValid())
67  {
68  throw cms::Exception ("RecoTrackAccumulator") << "Failed to find track collections with inputTag " << label << std::endl;
69  }
70  if(!hits.isValid())
71  {
72  throw cms::Exception ("RecoTrackAccumulator") << "Failed to find hit collections with inputTag " << label << std::endl;
73  }
74  if(!trackExtras.isValid())
75  {
76  throw cms::Exception ("RecoTrackAccumulator") << "Failed to find trackExtra collections with inputTag " << label << std::endl;
77  }
78 
79  for (size_t t = 0; t < tracks->size();++t){
80  const reco::Track & track = (*tracks)[t];
81  newTracks_->push_back(track);
82  // track extras:
83  auto const& extra = trackExtras->at(track.extra().key());
84  newTrackExtras_->emplace_back(extra.outerPosition(), extra.outerMomentum(), extra.outerOk(),
85  extra.innerPosition(),extra.innerMomentum(), extra.innerOk(),
86  extra.outerStateCovariance(), extra.outerDetId(),
87  extra.innerStateCovariance(), extra.innerDetId(),
88  extra.seedDirection(),
89  //If TrajectorySeeds are needed, then their list must be gotten from the
90  // secondary event directly and looked up similarly to TrackExtras.
91  //We can't use a default constructed RefToBase due to a bug in RefToBase
92  // which causes an seg fault when calling isAvailable on a default constructed one.
94  newTracks_->back().setExtra( reco::TrackExtraRef( rNewTrackExtras, newTracks_->size() - 1) );
95  // rechits:
96  // note: extra.recHit(i) does not work for pileup events
97  // probably the Ref does not know its product id applies on a pileup event
98  auto & newExtra = newTrackExtras_->back();
99  auto const firstTrackIndex = newHits_->size();
100  for(unsigned int i = 0;i<extra.recHitsSize();i++){
101  newHits_->push_back( (*hits)[extra.recHit(i).key()] );
102  }
103  newExtra.setHits( rNewHits, firstTrackIndex, newHits_->size() - firstTrackIndex);
104  }
105 }
106 
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int i
Definition: DBlmapReader.cc:9
void accumulateEvent(const T &e, edm::EventSetup const &c, const edm::InputTag &label)
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:189
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
key_type key() const
Accessor for product key.
Definition: Ref.h:264
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:121
TrackingRecHitRefProd rNewHits
reco::TrackRefProd rNewTracks
bool isValid() const
Definition: HandleBase.h:75
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
std::auto_ptr< reco::TrackExtraCollection > newTrackExtras_
tuple tracks
Definition: testEve_cfg.py:39
virtual void finalizeEvent(edm::Event &e, edm::EventSetup const &c)
virtual void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
#define DEFINE_DIGI_ACCUMULATOR(type)
std::auto_ptr< TrackingRecHitCollection > newHits_
std::auto_ptr< reco::TrackCollection > newTracks_
RecoTrackAccumulator(const edm::ParameterSet &conf, edm::stream::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
long double T
reco::TrackExtraRefProd rNewTrackExtras