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
RecoTrackAccumulator Class Reference

#include <RecoTrackAccumulator.h>

Inheritance diagram for RecoTrackAccumulator:
DigiAccumulatorMixMod

Public Member Functions

virtual void accumulate (edm::Event const &e, edm::EventSetup const &c)
 
virtual void accumulate (PileUpEventPrincipal const &e, edm::EventSetup const &c, edm::StreamID const &) override
 
virtual void finalizeEvent (edm::Event &e, edm::EventSetup const &c)
 
virtual void initializeEvent (edm::Event const &e, edm::EventSetup const &c)
 
 RecoTrackAccumulator (const edm::ParameterSet &conf, edm::one::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
 
virtual ~RecoTrackAccumulator ()
 
- Public Member Functions inherited from DigiAccumulatorMixMod
virtual void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup)
 
virtual void beginRun (edm::Run const &run, edm::EventSetup const &setup)
 
 DigiAccumulatorMixMod ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup)
 
virtual void endRun (edm::Run const &run, edm::EventSetup const &setup)
 
virtual void finalizeBunchCrossing (edm::Event &event, edm::EventSetup const &setup, int bunchCrossing)
 
virtual PileupMixingContentgetEventPileupInfo ()
 
virtual void initializeBunchCrossing (edm::Event const &event, edm::EventSetup const &setup, int bunchCrossing)
 
virtual void StorePileupInformation (std::vector< int > &numInteractionList, std::vector< int > &bunchCrossingList, std::vector< float > &TrueInteractionList, std::vector< edm::EventID > &eventList, int bunchSpace)
 
virtual ~DigiAccumulatorMixMod ()
 

Private Member Functions

template<class T >
void accumulateEvent (const T &e, edm::EventSetup const &c, const edm::InputTag &label, const edm::InputTag &MVALabel)
 

Private Attributes

std::string MVAOutputLabel
 
std::auto_ptr
< TrackingRecHitCollection
newHits_
 
std::vector< float > newMVAVals_
 
std::auto_ptr
< reco::TrackExtraCollection
newTrackExtras_
 
std::auto_ptr
< reco::TrackCollection
newTracks_
 
std::string outputLabel
 
edm::InputTag pileUpMVAValuesTag
 
edm::InputTag pileUpTracksTag
 
TrackingRecHitRefProd rNewHits
 
reco::TrackExtraRefProd rNewTrackExtras
 
reco::TrackRefProd rNewTracks
 
edm::InputTag signalMVAValuesTag
 
edm::InputTag signalTracksTag
 

Detailed Description

RecoTrackAccumulator accumulates generalTracks from the hard and the pileup events

Author
Andrea Giammanco
Version
Mar 11 2013

Definition at line 36 of file RecoTrackAccumulator.h.

Constructor & Destructor Documentation

RecoTrackAccumulator::RecoTrackAccumulator ( const edm::ParameterSet conf,
edm::one::EDProducerBase mixMod,
edm::ConsumesCollector iC 
)
explicit

Definition at line 9 of file RecoTrackAccumulator.cc.

References edm::ConsumesCollector::consumes(), MVAOutputLabel, outputLabel, signalMVAValuesTag, and signalTracksTag.

9  :
10  signalTracksTag(conf.getParameter<edm::InputTag>("signalTracks")),
11  signalMVAValuesTag(conf.getParameter<edm::InputTag>("signalMVAValues")),
12  pileUpTracksTag(conf.getParameter<edm::InputTag>("pileUpTracks")),
13  pileUpMVAValuesTag(conf.getParameter<edm::InputTag>("pileUpMVAValues")),
14  outputLabel(conf.getParameter<std::string>("outputLabel")),
15  MVAOutputLabel(conf.getParameter<std::string>("MVAOutputLabel"))
16 {
17  mixMod.produces<reco::TrackCollection>(outputLabel);
18  mixMod.produces<TrackingRecHitCollection>(outputLabel);
19  mixMod.produces<reco::TrackExtraCollection>(outputLabel);
20  mixMod.produces<edm::ValueMap<float> >(MVAOutputLabel);
21 
26 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::InputTag signalMVAValuesTag
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
edm::InputTag pileUpMVAValuesTag
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
RecoTrackAccumulator::~RecoTrackAccumulator ( )
virtual

Definition at line 28 of file RecoTrackAccumulator.cc.

28  {
29 
30 }

Member Function Documentation

void RecoTrackAccumulator::accumulate ( edm::Event const &  e,
edm::EventSetup const &  c 
)
virtual

Implements DigiAccumulatorMixMod.

Definition at line 45 of file RecoTrackAccumulator.cc.

References accumulateEvent(), signalMVAValuesTag, and signalTracksTag.

45  {
47 }
edm::InputTag signalMVAValuesTag
void accumulateEvent(const T &e, edm::EventSetup const &c, const edm::InputTag &label, const edm::InputTag &MVALabel)
void RecoTrackAccumulator::accumulate ( PileUpEventPrincipal const &  e,
edm::EventSetup const &  c,
edm::StreamID const &   
)
overridevirtual

Implements DigiAccumulatorMixMod.

Definition at line 49 of file RecoTrackAccumulator.cc.

References accumulateEvent(), PileUpEventPrincipal::bunchCrossing(), pileUpMVAValuesTag, and pileUpTracksTag.

49  {
50  if (e.bunchCrossing()==0) {
52  }
53 }
edm::InputTag pileUpMVAValuesTag
void accumulateEvent(const T &e, edm::EventSetup const &c, const edm::InputTag &label, const edm::InputTag &MVALabel)
template<class T >
void RecoTrackAccumulator::accumulateEvent ( const T e,
edm::EventSetup const &  c,
const edm::InputTag label,
const edm::InputTag MVALabel 
)
private

Definition at line 69 of file RecoTrackAccumulator.cc.

References cmsRelvalreport::exit, reco::Track::extra(), i, edm::HandleBase::id(), edm::Ref< C, T, F >::key(), diffTwoXMLs::label, newHits_, newMVAVals_, newTrackExtras_, newTracks_, rNewHits, rNewTrackExtras, edmStreamStallGrapher::t, and testEve_cfg::tracks.

Referenced by accumulate().

69  {
70 
75  if(!(e.getByLabel(label, tracks) and e.getByLabel(label, hits) and e.getByLabel(label, trackExtras))){
76  edm::LogError ("RecoTrackAccumulator") << "Failed to find track, hit or trackExtra collections with inputTag " << label;
77  exit(1);
78  }
79  else if(!e.getByLabel(MVALabel,mvaVals)){
80  edm::LogError ("RecoTrackAccumulator") << "Failed to find mva values with inputTag" << MVALabel;
81  exit(1);
82  }
83 
84  if(tracks->size() != mvaVals->size()){
85  edm::LogError("RecoTrackAccumulator") << "RecoTrackAccumulator expects the track collection and the MVA values to have the same number of entries" << std::endl;
86  }
87  if (tracks->size()==0)
88  return;
89 
90  // crude way to get the track product id
91  // (for PU events, the usual reco::TrackRef(tracks,t) does not result in a proper product id in the TrackRef)
92  edm::ProductID tracksProdId = mvaVals->begin().id();
93 
94  for (size_t t = 0; t < tracks->size();++t){
95  const reco::Track & track = tracks->at(t);
96  newTracks_->push_back(track);
97  // track extras:
98  auto const& extra = trackExtras->at(track.extra().key());
99  newTrackExtras_->emplace_back(extra.outerPosition(), extra.outerMomentum(), extra.outerOk(),
100  extra.innerPosition(),extra.innerMomentum(), extra.innerOk(),
101  extra.outerStateCovariance(), extra.outerDetId(),
102  extra.innerStateCovariance(), extra.innerDetId(),
103  extra.seedDirection(),
104  //If TrajectorySeeds are needed, then their list must be gotten from the
105  // secondary event directly and looked up similarly to TrackExtras.
106  //We can't use a default constructed RefToBase due to a bug in RefToBase
107  // which causes an seg fault when calling isAvailable on a default constructed one.
109  newTracks_->back().setExtra( reco::TrackExtraRef( rNewTrackExtras, newTracks_->size() - 1) );
110  // rechits:
111  // note: extra.recHit(i) does not work for pileup events
112  // probably the Ref does not know its product id applies on a pileup event
113  auto & newExtra = newTrackExtras_->back();
114  auto const firstTrackIndex = newHits_->size();
115  for(unsigned int i = 0;i<extra.recHitsSize();i++){
116  newHits_->push_back( (*hits)[extra.recHit(i).key()] );
117  }
118  newExtra.setHits( rNewHits, firstTrackIndex, newHits_->size() - firstTrackIndex);
119  // crude way to get the mva value that belongs to the track
120  // the usual way valueMap[trackref] does not work in PU events,
121  // see earlier comment about track id
122  float _val = mvaVals->get(tracksProdId,t);
123  newMVAVals_.push_back(_val);
124  }
125 }
int i
Definition: DBlmapReader.cc:9
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:189
ProductID id() const
Definition: HandleBase.cc:15
key_type key() const
Accessor for product key.
Definition: Ref.h:266
TrackingRecHitRefProd rNewHits
std::vector< float > newMVAVals_
std::auto_ptr< reco::TrackExtraCollection > newTrackExtras_
tuple tracks
Definition: testEve_cfg.py:39
std::auto_ptr< TrackingRecHitCollection > newHits_
std::auto_ptr< reco::TrackCollection > newTracks_
reco::TrackExtraRefProd rNewTrackExtras
void RecoTrackAccumulator::finalizeEvent ( edm::Event e,
edm::EventSetup const &  c 
)
virtual

Implements DigiAccumulatorMixMod.

Definition at line 55 of file RecoTrackAccumulator.cc.

References edm::helper::Filler< Map >::fill(), edm::RefProd< T >::id(), edm::helper::Filler< Map >::insert(), MVAOutputLabel, newHits_, newMVAVals_, newTrackExtras_, newTracks_, outputLabel, edm::Event::put(), and rNewTracks.

55  {
56 
57  std::auto_ptr< edm::ValueMap<float> > _newMVAVals(new edm::ValueMap<float>);
58  edm::ValueMap<float>::Filler filler(*_newMVAVals);
60  filler.insert(newTracksHandle,newMVAVals_.begin(),newMVAVals_.end());
61  filler.fill();
63  e.put( newHits_, outputLabel );
65  e.put(_newMVAVals,MVAOutputLabel);
66 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
reco::TrackRefProd rNewTracks
std::vector< float > newMVAVals_
std::auto_ptr< reco::TrackExtraCollection > newTrackExtras_
ProductID id() const
Accessor for product ID.
Definition: RefProd.h:140
std::auto_ptr< TrackingRecHitCollection > newHits_
std::auto_ptr< reco::TrackCollection > newTracks_
void RecoTrackAccumulator::initializeEvent ( edm::Event const &  e,
edm::EventSetup const &  c 
)
virtual

Implements DigiAccumulatorMixMod.

Definition at line 32 of file RecoTrackAccumulator.cc.

References alignCSCRings::e, newHits_, newMVAVals_, newTrackExtras_, newTracks_, outputLabel, rNewHits, rNewTrackExtras, and rNewTracks.

32  {
33 
34  newTracks_ = std::auto_ptr<reco::TrackCollection>(new reco::TrackCollection);
35  newHits_ = std::auto_ptr<TrackingRecHitCollection>(new TrackingRecHitCollection);
36  newTrackExtras_ = std::auto_ptr<reco::TrackExtraCollection>(new reco::TrackExtraCollection);
37  newMVAVals_.clear();
38 
39  // this is needed to get the ProductId of the TrackExtra and TrackingRecHit and Track collections
40  rNewTracks=const_cast<edm::Event&>( e ).getRefBeforePut<reco::TrackCollection>(outputLabel);
41  rNewTrackExtras=const_cast<edm::Event&>( e ).getRefBeforePut<reco::TrackExtraCollection>(outputLabel);
42  rNewHits=const_cast<edm::Event&>( e ).getRefBeforePut<TrackingRecHitCollection>(outputLabel);
43 }
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
TrackingRecHitRefProd rNewHits
reco::TrackRefProd rNewTracks
std::vector< float > newMVAVals_
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_
std::auto_ptr< TrackingRecHitCollection > newHits_
std::auto_ptr< reco::TrackCollection > newTracks_
reco::TrackExtraRefProd rNewTrackExtras

Member Data Documentation

std::string RecoTrackAccumulator::MVAOutputLabel
private

Definition at line 65 of file RecoTrackAccumulator.h.

Referenced by finalizeEvent(), and RecoTrackAccumulator().

std::auto_ptr<TrackingRecHitCollection> RecoTrackAccumulator::newHits_
private

Definition at line 52 of file RecoTrackAccumulator.h.

Referenced by accumulateEvent(), finalizeEvent(), and initializeEvent().

std::vector<float> RecoTrackAccumulator::newMVAVals_
private

Definition at line 53 of file RecoTrackAccumulator.h.

Referenced by accumulateEvent(), finalizeEvent(), and initializeEvent().

std::auto_ptr<reco::TrackExtraCollection> RecoTrackAccumulator::newTrackExtras_
private

Definition at line 51 of file RecoTrackAccumulator.h.

Referenced by accumulateEvent(), finalizeEvent(), and initializeEvent().

std::auto_ptr<reco::TrackCollection> RecoTrackAccumulator::newTracks_
private

Definition at line 50 of file RecoTrackAccumulator.h.

Referenced by accumulateEvent(), finalizeEvent(), and initializeEvent().

std::string RecoTrackAccumulator::outputLabel
private

Definition at line 64 of file RecoTrackAccumulator.h.

Referenced by finalizeEvent(), initializeEvent(), and RecoTrackAccumulator().

edm::InputTag RecoTrackAccumulator::pileUpMVAValuesTag
private

Definition at line 62 of file RecoTrackAccumulator.h.

Referenced by accumulate().

edm::InputTag RecoTrackAccumulator::pileUpTracksTag
private

Definition at line 61 of file RecoTrackAccumulator.h.

Referenced by accumulate().

TrackingRecHitRefProd RecoTrackAccumulator::rNewHits
private

Definition at line 57 of file RecoTrackAccumulator.h.

Referenced by accumulateEvent(), and initializeEvent().

reco::TrackExtraRefProd RecoTrackAccumulator::rNewTrackExtras
private

Definition at line 56 of file RecoTrackAccumulator.h.

Referenced by accumulateEvent(), and initializeEvent().

reco::TrackRefProd RecoTrackAccumulator::rNewTracks
private

Definition at line 55 of file RecoTrackAccumulator.h.

Referenced by finalizeEvent(), and initializeEvent().

edm::InputTag RecoTrackAccumulator::signalMVAValuesTag
private

Definition at line 60 of file RecoTrackAccumulator.h.

Referenced by accumulate(), and RecoTrackAccumulator().

edm::InputTag RecoTrackAccumulator::signalTracksTag
private

Definition at line 59 of file RecoTrackAccumulator.h.

Referenced by accumulate(), and RecoTrackAccumulator().