CMS 3D CMS Logo

GsfElectronSelector.h
Go to the documentation of this file.
1 #ifndef RecoAlgos_GsfElectronSelector_h
2 #define RecoAlgos_GsfElectronSelector_h
3 
23 
24 namespace helper {
35  }
36  template<typename I>
37  void cloneAndStore( const I & begin, const I & end, edm::Event & evt ) {
38  using namespace reco;
39  TrackingRecHitRefProd rHits = evt.template getRefBeforePut<TrackingRecHitCollection>();
40  TrackExtraRefProd rTrackExtras = evt.template getRefBeforePut<TrackExtraCollection>();
41  GsfTrackExtraRefProd rGsfTrackExtras = evt.template getRefBeforePut<GsfTrackExtraCollection>();
42  GsfTrackRefProd rTracks = evt.template getRefBeforePut<GsfTrackCollection>();
43  GsfElectronCoreRefProd rElectronCores = evt.template getRefBeforePut<GsfElectronCoreCollection>();
44  GsfElectronRefProd rElectrons = evt.template getRefBeforePut<GsfElectronCollection>();
45  SuperClusterRefProd rSuperClusters = evt.template getRefBeforePut<SuperClusterCollection>();
46  size_t idx = 0, tidx = 0, hidx = 0;
47  for( I i = begin; i != end; ++ i ) {
48  const GsfElectron & ele = * * i;
49  selElectronCores_->push_back( GsfElectronCore( *(ele.core()) ) );
50  selElectronCores_->back().setGsfTrack( GsfTrackRef( rTracks, idx ) );
51  selElectronCores_->back().setSuperCluster( SuperClusterRef( rSuperClusters, idx ) );
52  selSuperClusters_->push_back( SuperCluster( * ( ele.superCluster() ) ) );
54  GsfTrackRef trkRef = ele.gsfTrack();
55  if ( trkRef.isNonnull() ) {
56  selTracks_->push_back( GsfTrack( * trkRef ) );
57  GsfTrack & trk = selTracks_->back();
58  selTrackExtras_->push_back( TrackExtra( trk.outerPosition(), trk.outerMomentum(), trk.outerOk(),
59  trk.innerPosition(), trk.innerMomentum(), trk.innerOk(),
60  trk.outerStateCovariance(), trk.outerDetId(),
61  trk.innerStateCovariance(), trk.innerDetId(),
62  trk.seedDirection() ) );
63  selGsfTrackExtras_->push_back( GsfTrackExtra( *(trk.gsfExtra()) ) );
64  TrackExtra & tx = selTrackExtras_->back();
65  unsigned int nHitsToAdd = trk.recHitsSize();
66  for(auto const& hit : trk.recHits()) selHits_->push_back( hit->clone() );
67  tx.setHits( rHits, hidx, nHitsToAdd );
68  tx.setTrajParams(trk.extra()->trajParams(),trk.extra()->chi2sX5());
69  assert(tx.trajParams().size()==tx.recHitsSize());
70  hidx += nHitsToAdd;
71  trk.setGsfExtra( GsfTrackExtraRef( rGsfTrackExtras, tidx ) );
72  trk.setExtra( TrackExtraRef( rTrackExtras, tidx ++ ) );
73  }
74  }
75  }
76 
81  evt.put(std::move(selTracks_ ));
84  evt.put(std::move(selHits_ ));
85  return h;
86  }
87 
88  size_t size() const { return selElectrons_->size(); }
89  private:
90  std::unique_ptr<reco::GsfElectronCollection> selElectrons_;
91  std::unique_ptr<reco::GsfElectronCoreCollection> selElectronCores_;
92  std::unique_ptr<reco::SuperClusterCollection> selSuperClusters_;
93  std::unique_ptr<reco::GsfTrackCollection> selTracks_;
94  std::unique_ptr<reco::TrackExtraCollection> selTrackExtras_;
95  std::unique_ptr<reco::GsfTrackExtraCollection> selGsfTrackExtras_;
96  std::unique_ptr<TrackingRecHitCollection> selHits_;
97  };
98 
100  public:
102  std::string alias( cfg.getParameter<std::string>( "@module_label" ) );
103  produces<reco::GsfElectronCollection>().setBranchAlias( alias + "GsfElectrons" );
104  produces<reco::GsfElectronCoreCollection>().setBranchAlias( alias + "GsfElectronCores" );
105  produces<reco::SuperClusterCollection>().setBranchAlias( alias + "SuperClusters" );
106  produces<reco::GsfTrackCollection>().setBranchAlias( alias + "GsfTracks" );
107  produces<reco::GsfTrackExtraCollection>().setBranchAlias( alias + "GsfTrackExtras" );
108  produces<reco::TrackExtraCollection>().setBranchAlias( alias + "TrackExtras" );
109  produces<TrackingRecHitCollection>().setBranchAlias( alias + "RecHits" );
110  }
111  };
112 
113  template<>
117  };
118 }
119 
120 #endif
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
T getParameter(std::string const &) const
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:186
edm::Ref< GsfElectronCoreCollection > GsfElectronCoreRef
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
Definition: helper.py:1
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:194
void setGsfExtra(const GsfTrackExtraRef &ref)
set reference to GSF "extra" object
Definition: GsfTrack.h:30
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:124
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
std::vector< GsfTrackExtra > GsfTrackExtraCollection
collection of GsfTrackExtra objects
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:52
std::unique_ptr< reco::GsfTrackCollection > selTracks_
std::unique_ptr< reco::GsfElectronCollection > selElectrons_
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:17
edm::Ptr< CaloCluster > CaloClusterPtr
edm::OrphanHandle< reco::GsfElectronCollection > put(edm::Event &evt)
std::unique_ptr< TrackingRecHitCollection > selHits_
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:67
void cloneAndStore(const I &begin, const I &end, edm::Event &evt)
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:57
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:36
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
unsigned int recHitsSize() const
number of RecHits
TrajParams const & trajParams() const
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:77
std::vector< GsfElectronCore > GsfElectronCoreCollection
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
std::unique_ptr< reco::TrackExtraCollection > selTrackExtras_
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:96
auto recHits() const
Access to reconstructed hits on the track.
Definition: Track.h:106
const std::complex< double > I
Definition: I.h:8
edm::RefVector< GsfTrackCollection > GsfTrackRefVector
vector of reference to GsfTrack in the same collection
Definition: GsfTrackFwd.h:17
#define end
Definition: vmac.h:39
GsfElectronCollectionStoreManager(const edm::Handle< reco::GsfElectronCollection > &)
std::unique_ptr< reco::SuperClusterCollection > selSuperClusters_
edm::Ref< GsfTrackExtraCollection > GsfTrackExtraRef
persistent reference to a GsfTrackExtra
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
void setExtra(const TrackExtraRef &ref)
set reference to "extra" object
Definition: Track.h:189
const GsfTrackExtraRef & gsfExtra() const
reference to "extra" object
Definition: GsfTrack.h:32
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:72
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:47
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:209
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:21
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:82
std::unique_ptr< reco::GsfTrackExtraCollection > selGsfTrackExtras_
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
std::unique_ptr< reco::GsfElectronCoreCollection > selElectronCores_
fixed size matrix
#define begin
Definition: vmac.h:32
GsfElectronSelectorBase(const edm::ParameterSet &cfg)
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:62
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:185
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:101
def move(src, dest)
Definition: eostools.py:511
void setTrajParams(TrajParams tmps, Chi2sFive chi2s)