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  template <typename I>
36  void cloneAndStore(const I& begin, const I& end, edm::Event& evt) {
37  using namespace reco;
38  TrackingRecHitRefProd rHits = evt.template getRefBeforePut<TrackingRecHitCollection>();
39  TrackExtraRefProd rTrackExtras = evt.template getRefBeforePut<TrackExtraCollection>();
40  GsfTrackExtraRefProd rGsfTrackExtras = evt.template getRefBeforePut<GsfTrackExtraCollection>();
41  GsfTrackRefProd rTracks = evt.template getRefBeforePut<GsfTrackCollection>();
42  GsfElectronCoreRefProd rElectronCores = evt.template getRefBeforePut<GsfElectronCoreCollection>();
43  GsfElectronRefProd rElectrons = evt.template getRefBeforePut<GsfElectronCollection>();
44  SuperClusterRefProd rSuperClusters = evt.template getRefBeforePut<SuperClusterCollection>();
45  size_t idx = 0, tidx = 0, hidx = 0;
46  for (I i = begin; i != end; ++i) {
47  const GsfElectron& ele = **i;
48  selElectronCores_->push_back(GsfElectronCore(*(ele.core())));
49  selElectronCores_->back().setGsfTrack(GsfTrackRef(rTracks, idx));
50  selElectronCores_->back().setSuperCluster(SuperClusterRef(rSuperClusters, idx));
51  selSuperClusters_->push_back(SuperCluster(*(ele.superCluster())));
52  selElectrons_->push_back(GsfElectron(ele,
53  GsfElectronCoreRef(rElectronCores, idx++),
55  TrackRef(),
56  TrackBaseRef(),
58  GsfTrackRef trkRef = ele.gsfTrack();
59  if (trkRef.isNonnull()) {
60  selTracks_->push_back(GsfTrack(*trkRef));
61  GsfTrack& trk = selTracks_->back();
62  selTrackExtras_->push_back(TrackExtra(trk.outerPosition(),
63  trk.outerMomentum(),
64  trk.outerOk(),
65  trk.innerPosition(),
66  trk.innerMomentum(),
67  trk.innerOk(),
69  trk.outerDetId(),
71  trk.innerDetId(),
72  trk.seedDirection()));
73  selGsfTrackExtras_->push_back(GsfTrackExtra(*(trk.gsfExtra())));
74  TrackExtra& tx = selTrackExtras_->back();
75  unsigned int nHitsToAdd = trk.recHitsSize();
76  for (auto const& hit : trk.recHits())
77  selHits_->push_back(hit->clone());
78  tx.setHits(rHits, hidx, nHitsToAdd);
79  tx.setTrajParams(trk.extra()->trajParams(), trk.extra()->chi2sX5());
80  assert(tx.trajParams().size() == tx.recHitsSize());
81  hidx += nHitsToAdd;
82  trk.setGsfExtra(GsfTrackExtraRef(rGsfTrackExtras, tidx));
83  trk.setExtra(TrackExtraRef(rTrackExtras, tidx++));
84  }
85  }
86  }
87 
92  evt.put(std::move(selTracks_));
95  evt.put(std::move(selHits_));
96  return h;
97  }
98 
99  size_t size() const { return selElectrons_->size(); }
100 
101  private:
102  std::unique_ptr<reco::GsfElectronCollection> selElectrons_;
103  std::unique_ptr<reco::GsfElectronCoreCollection> selElectronCores_;
104  std::unique_ptr<reco::SuperClusterCollection> selSuperClusters_;
105  std::unique_ptr<reco::GsfTrackCollection> selTracks_;
106  std::unique_ptr<reco::TrackExtraCollection> selTrackExtras_;
107  std::unique_ptr<reco::GsfTrackExtraCollection> selGsfTrackExtras_;
108  std::unique_ptr<TrackingRecHitCollection> selHits_;
109  };
110 
112  public:
114  std::string alias(cfg.getParameter<std::string>("@module_label"));
115  produces<reco::GsfElectronCollection>().setBranchAlias(alias + "GsfElectrons");
116  produces<reco::GsfElectronCoreCollection>().setBranchAlias(alias + "GsfElectronCores");
117  produces<reco::SuperClusterCollection>().setBranchAlias(alias + "SuperClusters");
118  produces<reco::GsfTrackCollection>().setBranchAlias(alias + "GsfTracks");
119  produces<reco::GsfTrackExtraCollection>().setBranchAlias(alias + "GsfTrackExtras");
120  produces<reco::TrackExtraCollection>().setBranchAlias(alias + "TrackExtras");
121  produces<TrackingRecHitCollection>().setBranchAlias(alias + "RecHits");
122  }
123  };
124 
125  template <>
129  };
130 } // namespace helper
131 
132 #endif
reco::Track::outerPosition
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
reco::Track::outerMomentum
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:65
edm::RefProd< TrackingRecHitCollection >
GsfElectronCore.h
reco::GsfTrackRef
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
reco::Track::outerStateCovariance
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:68
ObjectSelector.h
helper::GsfElectronCollectionStoreManager::selElectronCores_
std::unique_ptr< reco::GsfElectronCoreCollection > selElectronCores_
Definition: GsfElectronSelector.h:103
reco::Track::outerDetId
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:79
mps_fire.i
i
Definition: mps_fire.py:355
reco::GsfElectron::gsfTrack
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:164
helper::GsfElectronCollectionStoreManager::selTrackExtras_
std::unique_ptr< reco::TrackExtraCollection > selTrackExtras_
Definition: GsfElectronSelector.h:106
GsfTrackExtra.h
helper::GsfElectronCollectionStoreManager::put
edm::OrphanHandle< reco::GsfElectronCollection > put(edm::Event &evt)
Definition: GsfElectronSelector.h:88
reco::SuperCluster
Definition: SuperCluster.h:18
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
reco::GsfTrackExtraCollection
std::vector< GsfTrackExtra > GsfTrackExtraCollection
collection of GsfTrackExtra objects
Definition: GsfTrackExtraFwd.h:9
cms::cuda::assert
assert(be >=bs)
reco::TrackBaseRef
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:35
reco::GsfElectronCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
Definition: GsfElectronFwd.h:14
helper::GsfElectronCollectionStoreManager::collection
reco::GsfElectronCollection collection
Definition: GsfElectronSelector.h:26
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::Track::outerOk
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:50
edm::Handle< reco::GsfElectronCollection >
training_settings.idx
idx
Definition: training_settings.py:16
reco::Track::extra
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:139
reco::CaloClusterPtr
edm::Ptr< CaloCluster > CaloClusterPtr
Definition: CaloClusterFwd.h:21
helper::StoreManagerTrait
Definition: StoreManagerTrait.h:91
end
#define end
Definition: vmac.h:39
edm::Ref< GsfTrackCollection >
reco::Track::innerStateCovariance
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:71
reco::Track::innerOk
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:53
helper::GsfElectronCollectionStoreManager::selGsfTrackExtras_
std::unique_ptr< reco::GsfTrackExtraCollection > selGsfTrackExtras_
Definition: GsfElectronSelector.h:107
reco::GsfElectron::core
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
reco::TrackExtra
Definition: TrackExtra.h:26
reco::GsfTrack
Definition: GsfTrack.h:12
TrackingRecHit.h
reco::Track::innerMomentum
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
reco::Track::recHitsSize
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits).
Definition: Track.h:97
h
Exhume::I
const std::complex< double > I
Definition: I.h:8
reco::GsfElectronCoreCollection
std::vector< GsfElectronCore > GsfElectronCoreCollection
Definition: GsfElectronCoreFwd.h:12
reco::SuperClusterRef
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
Definition: SuperClusterFwd.h:15
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
reco::Track::recHits
auto recHits() const
Access to reconstructed hits on the track.
Definition: Track.h:85
reco::GsfElectron
Definition: GsfElectron.h:35
GsfElectron.h
reco::GsfTrack::setGsfExtra
void setGsfExtra(const GsfTrackExtraRef &ref)
set reference to GSF "extra" object
Definition: GsfTrack.h:29
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::GsfTrack::gsfExtra
const GsfTrackExtraRef & gsfExtra() const
reference to "extra" object
Definition: GsfTrack.h:31
reco::TrackExtraBase::setTrajParams
void setTrajParams(TrajParams tmps, Chi2sFive chi2s)
Definition: TrackExtraBase.h:36
reco::Track::seedDirection
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:148
edm::ParameterSet
Definition: ParameterSet.h:36
reco::GsfTrackRefVector
edm::RefVector< GsfTrackCollection > GsfTrackRefVector
vector of reference to GsfTrack in the same collection
Definition: GsfTrackFwd.h:17
helper::StoreManagerTrait< reco::GsfElectronCollection >::type
GsfElectronCollectionStoreManager type
Definition: GsfElectronSelector.h:127
helper::GsfElectronSelectorBase
Definition: GsfElectronSelector.h:111
helper::GsfElectronCollectionStoreManager::selTracks_
std::unique_ptr< reco::GsfTrackCollection > selTracks_
Definition: GsfElectronSelector.h:105
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
helper
Definition: helper.py:1
reco::TrackExtraRef
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
reco::GsfElectronCore
Definition: GsfElectronCore.h:32
reco::Track::innerPosition
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
reco::TrackExtraBase::trajParams
TrajParams const & trajParams() const
Definition: TrackExtraBase.h:76
GsfTrack.h
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
reco::Track::innerDetId
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:82
edm::EDFilter
Definition: EDFilter.h:39
helper::GsfElectronCollectionStoreManager::selElectrons_
std::unique_ptr< reco::GsfElectronCollection > selElectrons_
Definition: GsfElectronSelector.h:102
helper::GsfElectronSelectorBase::GsfElectronSelectorBase
GsfElectronSelectorBase(const edm::ParameterSet &cfg)
Definition: GsfElectronSelector.h:113
helper::GsfElectronCollectionStoreManager::selSuperClusters_
std::unique_ptr< reco::SuperClusterCollection > selSuperClusters_
Definition: GsfElectronSelector.h:104
reco::TrackExtraBase::setHits
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
Definition: TrackExtraBase.h:30
looper.cfg
cfg
Definition: looper.py:297
reco::TrackExtraBase::recHitsSize
unsigned int recHitsSize() const
number of RecHits
Definition: TrackExtraBase.h:44
helper::StoreManagerTrait< reco::GsfElectronCollection >::base
GsfElectronSelectorBase base
Definition: GsfElectronSelector.h:128
reco::Track::setExtra
void setExtra(const TrackExtraRef &ref)
set reference to "extra" object
Definition: Track.h:136
helper::GsfElectronCollectionStoreManager
Definition: GsfElectronSelector.h:25
reco::GsfTrackCollection
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
SiStripOfflineCRack_cfg.alias
alias
Definition: SiStripOfflineCRack_cfg.py:129
SuperCluster.h
helper::GsfElectronCollectionStoreManager::cloneAndStore
void cloneAndStore(const I &begin, const I &end, edm::Event &evt)
Definition: GsfElectronSelector.h:36
reco::GsfElectron::superCluster
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:163
helper::GsfElectronCollectionStoreManager::size
size_t size() const
Definition: GsfElectronSelector.h:99
reco::GsfTrackExtra
Definition: GsfTrackExtra.h:16
reco::GsfTrackExtraRef
edm::Ref< GsfTrackExtraCollection > GsfTrackExtraRef
persistent reference to a GsfTrackExtra
Definition: GsfTrackExtraFwd.h:13
edm::Event
Definition: Event.h:73
helper::GsfElectronCollectionStoreManager::selHits_
std::unique_ptr< TrackingRecHitCollection > selHits_
Definition: GsfElectronSelector.h:108
begin
#define begin
Definition: vmac.h:32
helper::GsfElectronCollectionStoreManager::GsfElectronCollectionStoreManager
GsfElectronCollectionStoreManager(const edm::Handle< reco::GsfElectronCollection > &)
Definition: GsfElectronSelector.h:27
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector< TrackingRecHit >
reco::GsfElectronCoreRef
edm::Ref< GsfElectronCoreCollection > GsfElectronCoreRef
Definition: GsfElectronCoreFwd.h:14