CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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>
19 
23 
24 
25 
27 public:
28 
33 
34 
36 
37 
38  template<typename Producer>
39  TrackCollectionCloner(Producer & producer, const edm::ParameterSet & cfg, bool copyDefault ) :
40  copyExtras_(cfg.template getUntrackedParameter<bool>("copyExtras", copyDefault)),
41  copyTrajectories_(cfg.template getUntrackedParameter<bool>("copyTrajectories", copyDefault)) {
42 
43  std::string alias( cfg.getParameter<std::string>( "@module_label" ) );
44  producer.template produces<reco::TrackCollection>().setBranchAlias( alias + "Tracks" );
45  if (copyExtras_) {
46  producer.template produces<reco::TrackExtraCollection>().setBranchAlias( alias + "TrackExtras" );
47  producer.template produces<TrackingRecHitCollection>().setBranchAlias( alias + "RecHits" );
48  }
49  if (copyTrajectories_) {
50  producer.template produces< std::vector<Trajectory> >().setBranchAlias( alias + "Trajectories" );
51  producer.template produces< TrajTrackAssociationCollection >().setBranchAlias( alias + "TrajectoryTrackAssociations" );
52  }
53 
54  }
55 
56  static void fill(edm::ParameterSetDescription& desc);
57 
58  struct Producer {
60 
61  ~Producer();
62 
63  void operator()(Tokens const & tokens, std::vector<unsigned int> const & selected);
64 
69 
72  // some space
73  std::unique_ptr<reco::TrackCollection> selTracks_;
74  std::unique_ptr<reco::TrackExtraCollection> selTrackExtras_;
75  std::unique_ptr<TrackingRecHitCollection> selHits_;
76  std::unique_ptr< std::vector<Trajectory> > selTrajs_;
77  std::unique_ptr< TrajTrackAssociationCollection > selTTAss_;
78  };
79 
80 
81 };
82 
83 #endif
T getParameter(std::string const &) const
tuple cfg
Definition: looper.py:293
std::unique_ptr< std::vector< Trajectory > > selTrajs_
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
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
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
TrackCollectionCloner(Producer &producer, const edm::ParameterSet &cfg, bool copyDefault)
Producer(edm::Event &ievt, TrackCollectionCloner const &cloner)
bool copyTrajectories_
copy also trajectories and trajectory-&gt;track associations
def template
Definition: svgfig.py:520
void operator()(Tokens const &tokens, std::vector< unsigned int > const &selected)
process one event
std::unique_ptr< TrajTrackAssociationCollection > selTTAss_