CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
128  };
129 
130 } // namespace helper
131 
132 template <typename Selector,
133  typename StoreManagerTrait = ::helper::GsfElectronCollectionStoreManagerTrait,
134  typename OutputCollection =
137  typename PostProcessor = ::helper::NullPostProcessor<reco::GsfElectronCollection> >
139  Selector,
140  typename StoreManagerTrait::base,
141  OutputCollection,
142  StoreContainer,
143  PostProcessor,
144  typename StoreManagerTrait::type,
146 
147 #endif
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
CollectionStoreManager< OutputCollection > type
edm::Ref< GsfElectronCoreCollection > GsfElectronCoreRef
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
tuple cfg
Definition: looper.py:296
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:139
void setGsfExtra(const GsfTrackExtraRef &ref)
set reference to GSF &quot;extra&quot; object
Definition: GsfTrack.h:29
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:97
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:53
std::unique_ptr< reco::GsfTrackCollection > selTracks_
std::unique_ptr< reco::GsfElectronCollection > selElectrons_
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
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:62
assert(be >=bs)
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:56
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:35
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:68
std::vector< GsfElectronCore > GsfElectronCoreCollection
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
def move
Definition: eostools.py:511
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:79
auto recHits() const
Access to reconstructed hits on the track.
Definition: Track.h:85
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
Functor that operates on &lt;T&gt;
Definition: Selector.h:22
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:10
void setExtra(const TrackExtraRef &ref)
set reference to &quot;extra&quot; object
Definition: Track.h:136
const GsfTrackExtraRef & gsfExtra() const
reference to &quot;extra&quot; object
Definition: GsfTrack.h:31
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:65
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:50
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:148
ObjectSelectorBase< OutputCollection, EdmFilter > base
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:71
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< reco::GsfTrackExtraCollection > selGsfTrackExtras_
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
std::unique_ptr< reco::GsfElectronCoreCollection > selElectronCores_
GsfElectronSelectorBase(const edm::ParameterSet &cfg)
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
string end
Definition: dataset.py:937
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:82
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
void setTrajParams(TrajParams tmps, Chi2sFive chi2s)