CMS 3D CMS Logo

RecoTrackAccumulator.cc
Go to the documentation of this file.
6 
8  edm::ProducesCollector producesCollector,
10  : signalTracksTag(conf.getParameter<edm::InputTag>("signalTracks")),
11  pileUpTracksTag(conf.getParameter<edm::InputTag>("pileUpTracks")),
12  outputLabel(conf.getParameter<std::string>("outputLabel")) {
13  producesCollector.produces<reco::TrackCollection>(outputLabel);
14  producesCollector.produces<TrackingRecHitCollection>(outputLabel);
16 
20 }
21 
23 
25  newTracks_ = std::unique_ptr<reco::TrackCollection>(new reco::TrackCollection);
26  newHits_ = std::unique_ptr<TrackingRecHitCollection>(new TrackingRecHitCollection);
27  newTrackExtras_ = std::unique_ptr<reco::TrackExtraCollection>(new reco::TrackExtraCollection);
28 
29  // this is needed to get the ProductId of the TrackExtra and TrackingRecHit and Track collections
30  rNewTracks = const_cast<edm::Event&>(e).getRefBeforePut<reco::TrackCollection>(outputLabel);
31  rNewTrackExtras = const_cast<edm::Event&>(e).getRefBeforePut<reco::TrackExtraCollection>(outputLabel);
32  rNewHits = const_cast<edm::Event&>(e).getRefBeforePut<TrackingRecHitCollection>(outputLabel);
33 }
34 
37 }
38 
40  edm::EventSetup const& iSetup,
41  edm::StreamID const&) {
42  if (e.bunchCrossing() == 0) {
44  }
45 }
46 
51 }
52 
53 template <class T>
58  e.getByLabel(label, tracks);
59  e.getByLabel(label, hits);
60  e.getByLabel(label, trackExtras);
61 
62  if (!tracks.isValid()) {
63  throw cms::Exception("RecoTrackAccumulator")
64  << "Failed to find track collections with inputTag " << label << std::endl;
65  }
66  if (!hits.isValid()) {
67  throw cms::Exception("RecoTrackAccumulator")
68  << "Failed to find hit collections with inputTag " << label << std::endl;
69  }
70  if (!trackExtras.isValid()) {
71  throw cms::Exception("RecoTrackAccumulator")
72  << "Failed to find trackExtra collections with inputTag " << label << std::endl;
73  }
74 
75  for (size_t t = 0; t < tracks->size(); ++t) {
76  const reco::Track& track = (*tracks)[t];
77  newTracks_->push_back(track);
78  // track extras:
79  auto const& extra = trackExtras->at(track.extra().key());
80  newTrackExtras_->emplace_back(extra.outerPosition(),
81  extra.outerMomentum(),
82  extra.outerOk(),
83  extra.innerPosition(),
84  extra.innerMomentum(),
85  extra.innerOk(),
86  extra.outerStateCovariance(),
87  extra.outerDetId(),
88  extra.innerStateCovariance(),
89  extra.innerDetId(),
90  extra.seedDirection(),
91  //If TrajectorySeeds are needed, then their list must be gotten from the
92  // secondary event directly and looked up similarly to TrackExtras.
93  //We can't use a default constructed RefToBase due to a bug in RefToBase
94  // which causes an seg fault when calling isAvailable on a default constructed one.
96  newTracks_->back().setExtra(reco::TrackExtraRef(rNewTrackExtras, newTracks_->size() - 1));
97  // rechits:
98  // note: extra.recHit(i) does not work for pileup events
99  // probably the Ref does not know its product id applies on a pileup event
100  auto& newExtra = newTrackExtras_->back();
101  auto const firstTrackIndex = newHits_->size();
102  for (unsigned int i = 0; i < extra.recHitsSize(); i++) {
103  newHits_->push_back((*hits)[extra.recHit(i).key()]);
104  }
105  newExtra.setHits(rNewHits, firstTrackIndex, newHits_->size() - firstTrackIndex);
106  newExtra.setTrajParams(extra.trajParams(), extra.chi2sX5());
107  assert(newExtra.recHitsSize() == newExtra.trajParams().size());
108  }
109 }
110 
edm::StreamID
Definition: StreamID.h:30
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
RecoTrackAccumulator::pileUpTracksTag
edm::InputTag pileUpTracksTag
Definition: RecoTrackAccumulator.h:56
RecoTrackAccumulator::accumulateEvent
void accumulateEvent(const T &e, edm::EventSetup const &c, const edm::InputTag &label)
Definition: RecoTrackAccumulator.cc:54
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
RecoTrackAccumulator::rNewTrackExtras
reco::TrackExtraRefProd rNewTrackExtras
Definition: RecoTrackAccumulator.h:52
edm
HLT enums.
Definition: AlignableModifier.h:19
cms::cuda::assert
assert(be >=bs)
recoTrackAccumulator_cfi.outputLabel
outputLabel
Definition: recoTrackAccumulator_cfi.py:13
PileUpEventPrincipal
Definition: PileUpEventPrincipal.h:19
RecoTrackAccumulator::accumulate
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
Definition: RecoTrackAccumulator.cc:35
edm::Handle< reco::TrackCollection >
edm::Ref
Definition: AssociativeIterator.h:58
Track.h
RecoTrackAccumulator::initializeEvent
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
Definition: RecoTrackAccumulator.cc:24
reco::Track
Definition: Track.h:27
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
RecoTrackAccumulator::newTracks_
std::unique_ptr< reco::TrackCollection > newTracks_
Definition: RecoTrackAccumulator.h:47
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
RecoTrackAccumulator.h
OrderedSet.t
t
Definition: OrderedSet.py:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RecoTrackAccumulator::rNewTracks
reco::TrackRefProd rNewTracks
Definition: RecoTrackAccumulator.h:51
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
RecoTrackAccumulator::newHits_
std::unique_ptr< TrackingRecHitCollection > newHits_
Definition: RecoTrackAccumulator.h:49
edm::ProducesCollector::produces
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
Definition: ProducesCollector.h:52
edm::EventSetup
Definition: EventSetup.h:57
RecoTrackAccumulator::finalizeEvent
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
Definition: RecoTrackAccumulator.cc:47
ValueMap.h
RecoTrackAccumulator::rNewHits
TrackingRecHitRefProd rNewHits
Definition: RecoTrackAccumulator.h:53
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::ProducesCollector
Definition: ProducesCollector.h:43
RecoTrackAccumulator::newTrackExtras_
std::unique_ptr< reco::TrackExtraCollection > newTrackExtras_
Definition: RecoTrackAccumulator.h:48
RecoTrackAccumulator::signalTracksTag
edm::InputTag signalTracksTag
Definition: RecoTrackAccumulator.h:55
T
long double T
Definition: Basic3DVectorLD.h:48
Exception
Definition: hltDiff.cc:246
edm::RefToBase< TrajectorySeed >
RecoTrackAccumulator
Definition: RecoTrackAccumulator.h:33
RecoTrackAccumulator::RecoTrackAccumulator
RecoTrackAccumulator(const edm::ParameterSet &conf, edm::ProducesCollector, edm::ConsumesCollector &iC)
Definition: RecoTrackAccumulator.cc:7
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
ConsumesCollector.h
DigiAccumulatorMixModFactory.h
DEFINE_DIGI_ACCUMULATOR
#define DEFINE_DIGI_ACCUMULATOR(type)
Definition: DigiAccumulatorMixModFactory.h:31
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
label
const char * label
Definition: PFTauDecayModeTools.cc:11
RecoTrackAccumulator::~RecoTrackAccumulator
~RecoTrackAccumulator() override
Definition: RecoTrackAccumulator.cc:22
edm::OwnVector< TrackingRecHit >
RecoTrackAccumulator::outputLabel
std::string outputLabel
Definition: RecoTrackAccumulator.h:58
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37