CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TrackCollectionCloner.h
Go to the documentation of this file.
1 #ifndef RecoTracker_FinalTrackSelectors_TrackCollectionCloner_H
2 #define RecoTracker_FinalTrackSelectors_TrackCollectionCloner_H
3 /*
4  *
5  * selects a subset of a track collection, copying extra information on demand
6  * to be used moslty as an helper in the produce method of selectors
7  *
8  * \author Giovanni Petrucciani
9  *
10  *
11  *
12  */
13 
14 #include <utility>
15 #include <memory>
16 #include <algorithm>
20 
24 
26 public:
31 
33 
34  TrackCollectionCloner(edm::ProducesCollector producesCollector, const edm::ParameterSet& cfg, bool copyDefault)
35  : copyExtras_(cfg.template getUntrackedParameter<bool>("copyExtras", copyDefault)),
36  copyTrajectories_(cfg.template getUntrackedParameter<bool>("copyTrajectories", copyDefault)) {
37  std::string alias(cfg.getParameter<std::string>("@module_label"));
38  producesCollector.produces<reco::TrackCollection>().setBranchAlias(alias + "Tracks");
39  if (copyExtras_) {
40  producesCollector.produces<reco::TrackExtraCollection>().setBranchAlias(alias + "TrackExtras");
41  producesCollector.produces<TrackingRecHitCollection>().setBranchAlias(alias + "RecHits");
42  }
43  if (copyTrajectories_) {
44  producesCollector.produces<std::vector<Trajectory> >().setBranchAlias(alias + "Trajectories");
45  producesCollector.produces<TrajTrackAssociationCollection>().setBranchAlias(alias +
46  "TrajectoryTrackAssociations");
47  }
48  }
49 
51 
52  struct Producer {
53  Producer(edm::Event& ievt, TrackCollectionCloner const& cloner);
54 
55  ~Producer();
56 
57  void operator()(Tokens const& tokens, std::vector<unsigned int> const& selected);
58 
63 
66  // some space
67  std::unique_ptr<reco::TrackCollection> selTracks_;
68  std::unique_ptr<reco::TrackExtraCollection> selTrackExtras_;
69  std::unique_ptr<TrackingRecHitCollection> selHits_;
70  std::unique_ptr<std::vector<Trajectory> > selTrajs_;
71  std::unique_ptr<TrajTrackAssociationCollection> selTTAss_;
72  };
73 };
74 
75 #endif
std::unique_ptr< std::vector< Trajectory > > selTrajs_
tuple cfg
Definition: looper.py:296
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
static void fill(edm::ParameterSetDescription &desc)
std::unique_ptr< reco::TrackExtraCollection > selTrackExtras_
std::unique_ptr< reco::TrackCollection > selTracks_
std::unique_ptr< TrackingRecHitCollection > selHits_
bool copyTrajectories_
copy also trajectories and trajectory-&gt;track associations
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
std::unique_ptr< TrajTrackAssociationCollection > selTTAss_
Producer(edm::Event &ievt, TrackCollectionCloner const &cloner)
TrackCollectionCloner(edm::ProducesCollector producesCollector, const edm::ParameterSet &cfg, bool copyDefault)
bool copyTrajectories_
copy also trajectories and trajectory-&gt;track associations
def template
Definition: svgfig.py:521
void operator()(Tokens const &tokens, std::vector< unsigned int > const &selected)
process one event